@@ -116,8 +116,27 @@ Otherwise, the latest Bundler version is installed (except for Ruby 2.2 and 2.3
116116
117117This behavior can be customized, see [action.yml](action.yml) for details about the `bundler` input.
118118
119- # ## Caching `bundle install`
119+ # ## Caching `bundle install` automatically
120120
121+ This action provides a way to automatically run `bundle install` and cache the result :
122+ ` ` ` yaml
123+ - uses: ruby/setup-ruby@v1
124+ with:
125+ bundler-cache: true
126+ ` ` `
127+
128+ This caching speeds up installing gems significantly and avoids too many requests to RubyGems.org.
129+ It needs a `Gemfile` under the [`working-directory`](#working-directory).
130+ The caching works whether there is a `Gemfile.lock` or not.
131+ If there is a `Gemfile.lock`, `bundle config --local deployment true` is used.
132+
133+ To perform caching, this action will use `bundle config --local path vendor/bundle`.
134+ Therefore, the Bundler `path` should not be changed in your workflow for the cache to work.
135+
136+ # ## Caching `bundle install` manually
137+
138+ You can also cache gems manually,
139+ but this is not recommended because it is verbose and very difficult to use a correct cache key.
121140You can cache the installed gems with these two steps :
122141
123142` ` ` yaml
@@ -140,7 +159,8 @@ When using `.ruby-version`, replace `${{ matrix.ruby }}` with `${{ hashFiles('.r
140159When using `.tool-versions`, replace `${{ matrix.ruby }}` with `${{ hashFiles('.tool-versions') }}`.
141160
142161This uses the [cache action](https://github.com/actions/cache).
143- The code above is a more complete version of the [Ruby - Bundler example](https://github.com/actions/cache/blob/master/examples.md#ruby---bundler).
162+ The code above is a more complete version of the [Ruby - Bundler example](https://github.com/actions/cache/blob/master/examples.md#ruby---\
163+ bundler).
144164Make sure to include `use-ruby` in the `key` to avoid conflicting with previous caches.
145165
146166# ## Working Directory
0 commit comments