ruby/setup-ruby: Install Ruby & Bundler in CI
setup-ruby installs Ruby and can run bundler with caching in a single step.
Pin a Ruby version or read .ruby-version. Set bundler-cache: true and the action runs bundle install and caches gems for you.
Key inputs (with:)
- ruby-version: e.g. 3.3 or .ruby-version.
- bundler-cache: true to run bundle install with caching.
- bundler: pin a Bundler version.
- working-directory: where the Gemfile lives.
Example workflow
.github/workflows/ci.yml
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true
- run: bundle exec rakeOn any runner
setup-ruby runs on any runner. Latchkey managed runners run it unchanged.
Key takeaways
- bundler-cache: true replaces a manual bundle install plus cache.
- ruby-version: .ruby-version keeps CI aligned with local.
- Set working-directory for monorepos with nested Gemfiles.
Related guides
actions/checkout: Inputs & Workflow UsageReference for actions/checkout: clone your repository into the runner, control fetch-depth, submodules, refs,…
actions/cache: Save & Restore Build CachesReference for actions/cache: cache dependencies and build outputs across runs using key and restore-keys, wit…
codecov/codecov-action: Upload Coverage ReportsReference for codecov/codecov-action: upload test coverage reports to Codecov with a token, flags, and file p…