A GitHub Action that updates a Ruby gem using bundler and opens a pull request with the changes.
This action is designed to be used with workflow_dispatch to manually trigger gem updates. Add the following workflow to your repository.
Also enable Allow GitHub Actions to create and approve pull requests in repository settings.
name: Bump Gem
on:
workflow_dispatch:
inputs:
gem_name:
description: 'Name of the Ruby gem to update'
required: true
type: string
update_type:
description: 'Update type (major, minor, patch)'
required: false
type: choice
options:
- ''
- major
- minor
- patch
pre:
description: 'Include pre-release versions'
required: false
type: boolean
default: false
gem_version:
description: 'Specific version to update to'
required: false
type: string
jobs:
bump:
runs-on: ubuntu-latest
steps:
- uses: dentarg/bump@main
with:
gem_name: ${{ inputs.gem_name }}
update_type: ${{ inputs.update_type }}
pre: ${{ inputs.pre }}
gem_version: ${{ inputs.gem_version }}
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: dependenciesTo be able to trigger further workflow runs, the pull requests created are marked as draft, so you can use the ready_for_review trigger in your workflows to have them run when you mark the pull request as ready.
name: CI
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review] # this includes the defaults
jobs:
specs:
runs-on: ubuntu-latest
steps:
- run: my-test-commandSee action.yml.
- The Ruby version needs to be specified in
Gemfile.lock - The action runs
bundle update --conservative <gem_name>to update only the specified gem and its dependencies - If there are changes to
Gemfile.lock, it creates a pull request with the updates - The PR includes a descriptive title and body explaining the changes
# test main
bin/test
# test pull-request
bin/test <pull-request number>
# cleanup pull-request created from testing
bin/del <pull-request number>
# squash merge pull-request
bin/merge-pr <pull-request number>