From 51fcbf867f4cbbee99dfb8fed57cc5ad02665885 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 16 Apr 2026 20:48:15 +0200 Subject: [PATCH] Add CI workflow to raise gem update PRs Signed-off-by: Tim Meusel --- .github/workflows/components_update.yml | 65 +++++++++++++++++++++++++ README.md | 8 +++ tasks/update_gems.rake | 47 ++++++++++-------- 3 files changed, 101 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/components_update.yml diff --git a/.github/workflows/components_update.yml b/.github/workflows/components_update.yml new file mode 100644 index 00000000..a4db3d77 --- /dev/null +++ b/.github/workflows/components_update.yml @@ -0,0 +1,65 @@ +--- + +name: Update components + +on: + workflow_call: {} + schedule: + - cron: "0 0 * * *" + +env: + GIT_AUTHOR_NAME: OpenVoxProjectBot + GIT_AUTHOR_EMAIL: 215568489+OpenVoxProjectBot@users.noreply.github.com + GIT_COMMITTER_NAME: OpenVoxProjectBot + GIT_COMMITTER_EMAIL: 215568489+OpenVoxProjectBot@users.noreply.github.com + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + +permissions: + contents: read + +jobs: + update_gems: + name: 'Update gem components' + runs-on: ubuntu-24.04 + if: github.repository_owner == 'OpenVoxProject' + steps: + - name: Checkout repository + uses: actions/checkout@v6 + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + - name: Add SSH key + run: | + mkdir -p ~/.ssh + echo "${{ secrets.OPENVOXBOT_SSH_PRIVATE_KEY }}" > ~/.ssh/github_actions + chmod 600 ~/.ssh/github_actions + ssh-agent -a $SSH_AUTH_SOCK > /dev/null + ssh-add ~/.ssh/github_actions + - name: Setup git + run: | + git config --global user.email "$GIT_AUTHOR_EMAIL" + git config --global user.name "$GIT_AUTHOR_NAME" + git config --global gpg.format ssh + git config --global user.signingkey ~/.ssh/github_actions + git config --global commit.gpgsign true + git config --global tag.gpgsign true + - name: Display bundle environment + run: bundle env + - name: Check for gem updates + run: vox:update_gems + - name: Create pull Request + uses: peter-evans/create-pull-request@v8 + with: + commit-message: "Update Ruby components" + signoff: true + branch: "component-update" + delete-branch: true + title: "Update Ruby components" + labels: skip-changelog + token: '${{ secrets.OPENVOXBOT_COMMIT_AND_PRS }}' + assignees: '${{ github.triggering_actor }}' + author: '${{ env.GIT_AUTHOR_NAME }} <${{ env.GIT_AUTHOR_EMAIL }}>' + committer: '${{ env.GIT_COMMITTER_NAME }} <${{ env.GIT_COMMITTER_EMAIL }}>' + body: | + Automated gem update task diff --git a/README.md b/README.md index 9f313850..b707fec0 100644 --- a/README.md +++ b/README.md @@ -59,10 +59,18 @@ Where: ## Updating rubygem components This repo includes a rake task that will use the RubyGems API to update all rubygem components, including adding any missing runtime dependencies. + ``` $ bundle exec rake vox:update_gems ``` + +This is the all-in-one task, which will also commit your changes. +However, there is also `vox:update_gems_wo_commit`, which does the same except committing changes. +There's a CI workflow that runs daily + on demand. +It raises a PR / updates an existing PR if the rake task finds any changes. + In each `rubygem-*.rb` file in `configs/components`, you will find a "magic" block near the top. For example: + ``` ### Maintained by update_gems automation ### pkg.version '2.14.0' diff --git a/tasks/update_gems.rake b/tasks/update_gems.rake index 7c48d220..7c543add 100644 --- a/tasks/update_gems.rake +++ b/tasks/update_gems.rake @@ -483,30 +483,39 @@ def ensure_no_uncommitted_changes exit 1 end -namespace :vox do - desc 'Update rubygem components and print a summary of changes' - task :update_gems do - ensure_no_uncommitted_changes +def check_and_summarize(commit: true) + ensure_no_uncommitted_changes - progress_print('Updating components and creating missing ones') - update_all_components_and_create_missing - progress_clear + progress_print('Updating components and creating missing ones') + update_all_components_and_create_missing + progress_clear - progress_print('Ensuring project component dependencies') - ensure_projects_have_component_deps - progress_clear + progress_print('Ensuring project component dependencies') + ensure_projects_have_component_deps + progress_clear - summary = build_summary + summary = build_summary - if summary.empty? - puts 'No updates to any rubygem components needed' - exit 0 - end + if summary.empty? + puts 'No updates to any rubygem components needed' + exit 0 + end - puts summary + puts summary - git_add - git_commit(summary) - git_summary + return unless commit + + git_add + git_commit(summary) + git_summary +end +namespace :vox do + desc 'Update rubygem components, commit them and print a summary of changes' + task :update_gems do + check_and_summarize(commit: true) + end + desc 'Update rubygem components, commit them and print a summary of changes' + task :update_gems_wo_commit do + check_and_summarize(commit: false) end end