Skip to content

Commit 51f9fc6

Browse files
committed
Show a full example for caching bundle install
* Which should help avoid conflicts with previous caches * See #7
1 parent 0b83c28 commit 51f9fc6

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,26 @@ Otherwise (Ruby < 2.6), Bundler 1 is installed when that Ruby was built.
9292

9393
### Caching `bundle install`
9494

95-
See this [example](https://github.com/actions/cache/blob/master/examples.md#ruby---gem) using [actions/cache](https://github.com/actions/cache).
95+
You can cache the installed gems with these two steps:
96+
97+
```yaml
98+
- uses: actions/cache@v1
99+
with:
100+
path: vendor/bundle
101+
key: bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/Gemfile.lock') }}
102+
restore-keys: |
103+
bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby }}-
104+
- name: Bundle install
105+
run: |
106+
bundle config path vendor/bundle
107+
bundle install --jobs 4 --retry 3
108+
```
109+
110+
When using a single job, replace `${{ matrix.ruby }}` with the ruby version used or `${{ hashFiles('.ruby-version') }}`.
111+
112+
This uses the [cache action](https://github.com/actions/cache).
113+
The code above is more complete version of the [Gem example](https://github.com/actions/cache/blob/master/examples.md#ruby---gem).
114+
Make sure to include `use-ruby` in the `key` to avoid conflicting with previous caches.
96115

97116
## Limitations
98117

dist/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)