Skip to content

Commit 51fcbf8

Browse files
committed
Add CI workflow to raise gem update PRs
Signed-off-by: Tim Meusel <tim@bastelfreak.de>
1 parent 352add5 commit 51fcbf8

3 files changed

Lines changed: 101 additions & 19 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
3+
name: Update components
4+
5+
on:
6+
workflow_call: {}
7+
schedule:
8+
- cron: "0 0 * * *"
9+
10+
env:
11+
GIT_AUTHOR_NAME: OpenVoxProjectBot
12+
GIT_AUTHOR_EMAIL: 215568489+OpenVoxProjectBot@users.noreply.github.com
13+
GIT_COMMITTER_NAME: OpenVoxProjectBot
14+
GIT_COMMITTER_EMAIL: 215568489+OpenVoxProjectBot@users.noreply.github.com
15+
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
update_gems:
22+
name: 'Update gem components'
23+
runs-on: ubuntu-24.04
24+
if: github.repository_owner == 'OpenVoxProject'
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v6
28+
- name: Setup Ruby
29+
uses: ruby/setup-ruby@v1
30+
with:
31+
bundler-cache: true
32+
- name: Add SSH key
33+
run: |
34+
mkdir -p ~/.ssh
35+
echo "${{ secrets.OPENVOXBOT_SSH_PRIVATE_KEY }}" > ~/.ssh/github_actions
36+
chmod 600 ~/.ssh/github_actions
37+
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
38+
ssh-add ~/.ssh/github_actions
39+
- name: Setup git
40+
run: |
41+
git config --global user.email "$GIT_AUTHOR_EMAIL"
42+
git config --global user.name "$GIT_AUTHOR_NAME"
43+
git config --global gpg.format ssh
44+
git config --global user.signingkey ~/.ssh/github_actions
45+
git config --global commit.gpgsign true
46+
git config --global tag.gpgsign true
47+
- name: Display bundle environment
48+
run: bundle env
49+
- name: Check for gem updates
50+
run: vox:update_gems
51+
- name: Create pull Request
52+
uses: peter-evans/create-pull-request@v8
53+
with:
54+
commit-message: "Update Ruby components"
55+
signoff: true
56+
branch: "component-update"
57+
delete-branch: true
58+
title: "Update Ruby components"
59+
labels: skip-changelog
60+
token: '${{ secrets.OPENVOXBOT_COMMIT_AND_PRS }}'
61+
assignees: '${{ github.triggering_actor }}'
62+
author: '${{ env.GIT_AUTHOR_NAME }} <${{ env.GIT_AUTHOR_EMAIL }}>'
63+
committer: '${{ env.GIT_COMMITTER_NAME }} <${{ env.GIT_COMMITTER_EMAIL }}>'
64+
body: |
65+
Automated gem update task

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,18 @@ Where:
5959
## Updating rubygem components
6060

6161
This repo includes a rake task that will use the RubyGems API to update all rubygem components, including adding any missing runtime dependencies.
62+
6263
```
6364
$ bundle exec rake vox:update_gems
6465
```
66+
67+
This is the all-in-one task, which will also commit your changes.
68+
However, there is also `vox:update_gems_wo_commit`, which does the same except committing changes.
69+
There's a CI workflow that runs daily + on demand.
70+
It raises a PR / updates an existing PR if the rake task finds any changes.
71+
6572
In each `rubygem-*.rb` file in `configs/components`, you will find a "magic" block near the top. For example:
73+
6674
```
6775
### Maintained by update_gems automation ###
6876
pkg.version '2.14.0'

tasks/update_gems.rake

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -483,30 +483,39 @@ def ensure_no_uncommitted_changes
483483
exit 1
484484
end
485485

486-
namespace :vox do
487-
desc 'Update rubygem components and print a summary of changes'
488-
task :update_gems do
489-
ensure_no_uncommitted_changes
486+
def check_and_summarize(commit: true)
487+
ensure_no_uncommitted_changes
490488

491-
progress_print('Updating components and creating missing ones')
492-
update_all_components_and_create_missing
493-
progress_clear
489+
progress_print('Updating components and creating missing ones')
490+
update_all_components_and_create_missing
491+
progress_clear
494492

495-
progress_print('Ensuring project component dependencies')
496-
ensure_projects_have_component_deps
497-
progress_clear
493+
progress_print('Ensuring project component dependencies')
494+
ensure_projects_have_component_deps
495+
progress_clear
498496

499-
summary = build_summary
497+
summary = build_summary
500498

501-
if summary.empty?
502-
puts 'No updates to any rubygem components needed'
503-
exit 0
504-
end
499+
if summary.empty?
500+
puts 'No updates to any rubygem components needed'
501+
exit 0
502+
end
505503

506-
puts summary
504+
puts summary
507505

508-
git_add
509-
git_commit(summary)
510-
git_summary
506+
return unless commit
507+
508+
git_add
509+
git_commit(summary)
510+
git_summary
511+
end
512+
namespace :vox do
513+
desc 'Update rubygem components, commit them and print a summary of changes'
514+
task :update_gems do
515+
check_and_summarize(commit: true)
516+
end
517+
desc 'Update rubygem components, commit them and print a summary of changes'
518+
task :update_gems_wo_commit do
519+
check_and_summarize(commit: false)
511520
end
512521
end

0 commit comments

Comments
 (0)