Long story short, in my organization, I'm responsible for upgrading our Rails application. First thing I checked was every gems that could be updated right away.
I quickly found the outdated
command from bundler
.
I ran it with the options --only-explicit --strict
to check what is explicitly specified in my Gemfile and for what I can simply do bundle update <<gem>
without changing the requested version in my Gemfile.
Without much of a surprise, we had more than 70 gems that could be updated right away.
To prevent being in a similar situation in a few months or years, I had the idea to run the 'bundle outdated' command automatically, so I can keep track of new gem release. My solution was to create a script that can run in a Github Action to keep a Github Issue updated with the list of all outdated gems and their newer versions. So now I can easily see many dependencies that can be updated.
How it works
You need to create a Github Action, it can be done by creating a .yml
file under .github/workflows
in your project. You will also need a Github private access token with the scope repo
to be able to update the relative Github Issue. You can use the example in the README of the project.
In the example, the action runs on every push on master, which is convenient in a very active project and to have a live update of the issue if you merged an update. You can also choose to use a cron rule, which can be useful with a less active project.
When the action runs it will,
- Setup a Ruby environment with the version you specified in the
.yml
file - Pull the script
- Download the Gemfile and Gemfile.lock files from your project
- Run the command
bundle outdated --only-explicit --strict
- Create or update the description of the associated issue
Bhacaz / bundler-outdated-action
Script to use in a Github Actions to list in a issue the outdated gems
bundler-outdated-action
Use Github Actions to create and update a Github issue with the gems in your project that can be updated.
The result look like this:
bundle outdated --strict
Gem | Current | Newest | Groups |
---|---|---|---|
byebug | 11.1.1 | 11.1.3 | development, test |
figaro | 1.1.1 | 1.2.0 | default |
sidekiq | 6.0.6 | 6.0.7 | default |
web-console | 4.0.1 | 4.0.2 | development |
To use
- Create a new workflows in your project (
.github/workflows/outdated_gems.yml
) - Create a Personal access tokens with the scope
repo
- Add the token in the secrets of your repository with the name
GH_TOKEN
Example:
name: 'Outdated Gems'
on:
push:
branches:
- master
jobs:
outdated_gems:
runs-on: ubuntu-latest
name: Outdated gems
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
- name: 'Pull outdated gem action script'
uses: actions/checkout@v4
with:
repository: 'Bhacaz/bundler-outdated-action
…Happy updating
Top comments (0)