11name : Setup Bundler dependencies
2- description : Cache and install Ruby gems for a Bundler project.
2+ description : Setup Ruby, cache, and install gems for a Bundler project.
33
44inputs :
55 working-directory :
@@ -8,22 +8,18 @@ inputs:
88 ruby-version :
99 description : Ruby version used by the job.
1010 required : true
11- bundle-path :
12- description : Bundler install path, relative to the working directory.
13- required : false
14- default : vendor/bundle
1511 frozen :
16- description : Whether to run Bundler in frozen mode. Cache saving is disabled when false; restore still runs.
12+ description : Whether to run Bundler in frozen mode.
1713 required : false
1814 default : ' true'
1915 bundler-version :
20- description : Bundler version selector. Use lockfile, system , or x.y.z.
16+ description : Bundler version selector. Use Gemfile.lock, default, latest, none , or x.y.z.
2117 required : false
22- default : lockfile
23- install-args :
24- description : Arguments for bundle install .
18+ default : Gemfile.lock
19+ cache-version :
20+ description : Arbitrary cache-version value passed through to ruby/setup-ruby .
2521 required : false
26- default : --jobs=4 --retry=3
22+ default : ' 0 '
2723
2824runs :
2925 using : composite
@@ -37,36 +33,14 @@ runs:
3733 exit 1
3834 fi
3935
40- - name : Restore Ruby gems cache
41- id : restore-ruby-gems-cache
42- uses : actions/cache/restore@v5
43- with :
44- path : ${{ inputs.working-directory }}/${{ inputs.bundle-path }}
45- # Update to bundle-...-v1 in the future to break the cache if necessary
46- # or v1-bundle-... if you want restore-keys not to trigger either (update the key there in that case)
47- key : bundle-${{ runner.os }}-${{ inputs.working-directory }}-${{ inputs.bundle-path }}-ruby${{ inputs.ruby-version }}-${{ hashFiles(format('{0}/Gemfile.lock', inputs.working-directory)) }}
48- restore-keys : |
49- bundle-${{ runner.os }}-${{ inputs.working-directory }}-${{ inputs.bundle-path }}-ruby${{ inputs.ruby-version }}-
50-
51- - name : Install Ruby gems
52- shell : bash
53- working-directory : ${{ inputs.working-directory }}
36+ - name : Setup Ruby and install cached gems
37+ uses : ruby/setup-ruby@v1
5438 env :
5539 BUNDLE_FROZEN : ${{ inputs.frozen }}
56- BUNDLE_INSTALL_ARGS : ${{ inputs.install-args }}
57- BUNDLE_PATH_CONFIG : ${{ inputs.bundle-path }}
58- BUNDLER_VERSION_CONFIG : ${{ inputs.bundler-version }}
59- run : |
60- bundle config set --local path "$BUNDLE_PATH_CONFIG"
61- bundle config set --local version "$BUNDLER_VERSION_CONFIG"
62- # shellcheck disable=SC2086
63- # Intentionally allow install args to split into separate bundle arguments
64- bundle check || bundle install $BUNDLE_INSTALL_ARGS
65-
66- - name : Save Ruby gems cache
67- # We don't want to overwrite the cache for non-frozen Bundler runs
68- if : inputs.frozen == 'true' && steps.restore-ruby-gems-cache.outputs.cache-hit != 'true'
69- uses : actions/cache/save@v5
40+ BUNDLE_RETRY : ' 3'
7041 with :
71- path : ${{ inputs.working-directory }}/${{ inputs.bundle-path }}
72- key : ${{ steps.restore-ruby-gems-cache.outputs.cache-primary-key }}
42+ ruby-version : ${{ inputs.ruby-version }}
43+ working-directory : ${{ inputs.working-directory }}
44+ bundler : ${{ inputs.bundler-version }}
45+ bundler-cache : true
46+ cache-version : ${{ inputs.cache-version }}
0 commit comments