@@ -116,8 +116,27 @@ Otherwise, the latest Bundler version is installed (except for Ruby 2.2 and 2.3
116
116
117
117
This behavior can be customized, see [action.yml](action.yml) for details about the `bundler` input.
118
118
119
- # ## Caching `bundle install`
119
+ # ## Caching `bundle install` automatically
120
120
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.
121
140
You can cache the installed gems with these two steps :
122
141
123
142
` ` ` yaml
@@ -140,7 +159,8 @@ When using `.ruby-version`, replace `${{ matrix.ruby }}` with `${{ hashFiles('.r
140
159
When using `.tool-versions`, replace `${{ matrix.ruby }}` with `${{ hashFiles('.tool-versions') }}`.
141
160
142
161
This 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).
144
164
Make sure to include `use-ruby` in the `key` to avoid conflicting with previous caches.
145
165
146
166
# ## Working Directory
0 commit comments