From d4a762e005503347ffdafb274ecbf02879763149 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Tue, 7 Oct 2025 20:33:01 -0700 Subject: [PATCH 1/4] check_misc.yml: Support non-master branches See also: https://github.com/ruby/git.ruby-lang.org/commit/0b0eae90f67e9889b133b86b1f2e4526a2882161 --- .github/workflows/check_misc.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check_misc.yml b/.github/workflows/check_misc.yml index 67a350db1c887f..6638b0ec875fa5 100644 --- a/.github/workflows/check_misc.yml +++ b/.github/workflows/check_misc.yml @@ -37,15 +37,16 @@ jobs: # Sync git.ruby-lang.org before pushing new commits to avoid duplicated syncs - name: Sync git.ruby-lang.org - env: - RUBY_GIT_SYNC_PRIVATE_KEY: ${{ secrets.RUBY_GIT_SYNC_PRIVATE_KEY }} run: | mkdir -p ~/.ssh echo "$RUBY_GIT_SYNC_PRIVATE_KEY" > ~/.ssh/id_ed25519 chmod 600 ~/.ssh/id_ed25519 ssh-keyscan -t ed25519 git.ruby-lang.org >> ~/.ssh/known_hosts - ssh -i ~/.ssh/id_ed25519 git-sync@git.ruby-lang.org 'sudo -u git /home/git/git.ruby-lang.org/bin/update-ruby.sh master' - if: ${{ github.repository == 'ruby/ruby' && github.ref == 'refs/heads/master' && github.event_name == 'push' }} + ssh -i ~/.ssh/id_ed25519 git-sync@git.ruby-lang.org "sudo -u git /home/git/git.ruby-lang.org/bin/update-ruby.sh $GITHUB_REF" + env: + GITHUB_REF: ${{ github.ref }} + RUBY_GIT_SYNC_PRIVATE_KEY: ${{ secrets.RUBY_GIT_SYNC_PRIVATE_KEY }} + if: ${{ github.repository == 'ruby/ruby' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/ruby_')) && github.event_name == 'push' }} - uses: ./.github/actions/setup/directories with: From 76b10394856d62e56ab2f31f4bbfded320ce813d Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Tue, 7 Oct 2025 20:54:37 -0700 Subject: [PATCH 2/4] Carve out a workflow for post-push hooks (#14768) from check_misc.yml. These steps originally came from git.ruby-lang.org/ruby.git's post-receive hooks. Because it handles a different set of events from what the original check_misc.yml does, it probably allows them to be simpler if they are separated. --- .github/workflows/check_misc.yml | 50 +-------------------- .github/workflows/post_push.yml | 74 ++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 49 deletions(-) create mode 100644 .github/workflows/post_push.yml diff --git a/.github/workflows/check_misc.yml b/.github/workflows/check_misc.yml index 6638b0ec875fa5..1c0120252fdf21 100644 --- a/.github/workflows/check_misc.yml +++ b/.github/workflows/check_misc.yml @@ -20,52 +20,14 @@ jobs: steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: - fetch-depth: 100 # for notify-slack-commits token: ${{ (github.repository == 'ruby/ruby' && !startsWith(github.event_name, 'pull')) && secrets.MATZBOT_AUTO_UPDATE_TOKEN || secrets.GITHUB_TOKEN }} - # Run this step first (even before `make up` in the next step) to make the notification available before any other failure - - name: Notify commit to Slack - run: ruby tool/notify-slack-commits.rb "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA" refs/heads/master - env: - GITHUB_OLD_SHA: ${{ github.event.before }} - GITHUB_NEW_SHA: ${{ github.event.after }} - SLACK_WEBHOOK_URL_ALERTS: ${{ secrets.SLACK_WEBHOOK_URL_ALERTS }} - SLACK_WEBHOOK_URL_COMMITS: ${{ secrets.SLACK_WEBHOOK_URL_COMMITS }} - SLACK_WEBHOOK_URL_RUBY_JP: ${{ secrets.SLACK_WEBHOOK_URL_RUBY_JP }} - if: ${{ github.repository == 'ruby/ruby' && github.ref == 'refs/heads/master' && github.event_name == 'push' }} - continue-on-error: true # The next auto-style should always run - - # Sync git.ruby-lang.org before pushing new commits to avoid duplicated syncs - - name: Sync git.ruby-lang.org - run: | - mkdir -p ~/.ssh - echo "$RUBY_GIT_SYNC_PRIVATE_KEY" > ~/.ssh/id_ed25519 - chmod 600 ~/.ssh/id_ed25519 - ssh-keyscan -t ed25519 git.ruby-lang.org >> ~/.ssh/known_hosts - ssh -i ~/.ssh/id_ed25519 git-sync@git.ruby-lang.org "sudo -u git /home/git/git.ruby-lang.org/bin/update-ruby.sh $GITHUB_REF" - env: - GITHUB_REF: ${{ github.ref }} - RUBY_GIT_SYNC_PRIVATE_KEY: ${{ secrets.RUBY_GIT_SYNC_PRIVATE_KEY }} - if: ${{ github.repository == 'ruby/ruby' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/ruby_')) && github.event_name == 'push' }} - - uses: ./.github/actions/setup/directories with: makeup: true # Skip overwriting MATZBOT_AUTO_UPDATE_TOKEN checkout: '' # false (ref: https://github.com/actions/runner/issues/2238) - # Run this step early to make sure auto-style commits are pushed - - name: Auto-correct code styles - run: | - set -x - ruby tool/auto-style.rb "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA" refs/heads/master - env: - GITHUB_OLD_SHA: ${{ github.event.before }} - GITHUB_NEW_SHA: ${{ github.event.after }} - GIT_AUTHOR_NAME: git - GIT_COMMITTER_NAME: git - EMAIL: svn-admin@ruby-lang.org - if: ${{ github.repository == 'ruby/ruby' && github.ref == 'refs/heads/master' && github.event_name == 'push' }} - name: Check for code styles run: | set -x @@ -73,6 +35,7 @@ jobs: env: GITHUB_OLD_SHA: ${{ github.event.pull_request.base.sha }} GITHUB_NEW_SHA: ${{ github.event.pull_request.merge_commit_sha }} + # Skip 'push' events because post_push.yml fixes them on push if: ${{ github.repository == 'ruby/ruby' && startsWith(github.event_name, 'pull') }} - name: Check if C-sources are US-ASCII @@ -145,17 +108,6 @@ jobs: name: ${{ steps.docs.outputs.htmlout }} if: ${{ steps.docs.outcome == 'success' }} - - name: Push PR notes to GitHub - run: ruby tool/notes-github-pr.rb "$(pwd)/.git" "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA" refs/heads/master - env: - GITHUB_OLD_SHA: ${{ github.event.before }} - GITHUB_NEW_SHA: ${{ github.event.after }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GIT_AUTHOR_NAME: git - GIT_COMMITTER_NAME: git - EMAIL: svn-admin@ruby-lang.org - if: ${{ github.repository == 'ruby/ruby' && github.ref == 'refs/heads/master' && github.event_name == 'push' }} - - uses: ./.github/actions/slack with: SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot diff --git a/.github/workflows/post_push.yml b/.github/workflows/post_push.yml new file mode 100644 index 00000000000000..724a67017aa49f --- /dev/null +++ b/.github/workflows/post_push.yml @@ -0,0 +1,74 @@ +name: Post-push +on: push +jobs: + hooks: + name: Post-push hooks + + permissions: + contents: write # for Git to git push + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + fetch-depth: 500 # for notify-slack-commits + token: ${{ (github.repository == 'ruby/ruby' && !startsWith(github.event_name, 'pull')) && secrets.MATZBOT_AUTO_UPDATE_TOKEN || secrets.GITHUB_TOKEN }} + + # Run this step first (even before `make up` in the next step) to make the notification available before any other failure + - name: Notify commit to Slack + run: ruby tool/notify-slack-commits.rb "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA" refs/heads/master + env: + GITHUB_OLD_SHA: ${{ github.event.before }} + GITHUB_NEW_SHA: ${{ github.event.after }} + SLACK_WEBHOOK_URL_ALERTS: ${{ secrets.SLACK_WEBHOOK_URL_ALERTS }} + SLACK_WEBHOOK_URL_COMMITS: ${{ secrets.SLACK_WEBHOOK_URL_COMMITS }} + SLACK_WEBHOOK_URL_RUBY_JP: ${{ secrets.SLACK_WEBHOOK_URL_RUBY_JP }} + if: ${{ github.repository == 'ruby/ruby' && github.ref == 'refs/heads/master' && github.event_name == 'push' }} + continue-on-error: true # The next auto-style should always run + + - name: Sync git.ruby-lang.org + run: | + mkdir -p ~/.ssh + echo "$RUBY_GIT_SYNC_PRIVATE_KEY" > ~/.ssh/id_ed25519 + chmod 600 ~/.ssh/id_ed25519 + ssh-keyscan -t ed25519 git.ruby-lang.org >> ~/.ssh/known_hosts + ssh -i ~/.ssh/id_ed25519 git-sync@git.ruby-lang.org "sudo -u git /home/git/git.ruby-lang.org/bin/update-ruby.sh $GITHUB_REF" + env: + GITHUB_REF: ${{ github.ref }} + RUBY_GIT_SYNC_PRIVATE_KEY: ${{ secrets.RUBY_GIT_SYNC_PRIVATE_KEY }} + if: ${{ github.repository == 'ruby/ruby' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/ruby_')) && github.event_name == 'push' }} + + - uses: ./.github/actions/setup/directories + with: + makeup: true + # Skip overwriting MATZBOT_AUTO_UPDATE_TOKEN + checkout: '' # false (ref: https://github.com/actions/runner/issues/2238) + + - name: Auto-correct code styles + run: | + set -x + ruby tool/auto-style.rb "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA" refs/heads/master + env: + GITHUB_OLD_SHA: ${{ github.event.before }} + GITHUB_NEW_SHA: ${{ github.event.after }} + GIT_AUTHOR_NAME: git + GIT_COMMITTER_NAME: git + EMAIL: svn-admin@ruby-lang.org + if: ${{ github.repository == 'ruby/ruby' && github.ref == 'refs/heads/master' && github.event_name == 'push' }} + + - name: Push PR notes to GitHub + run: ruby tool/notes-github-pr.rb "$(pwd)/.git" "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA" refs/heads/master + env: + GITHUB_OLD_SHA: ${{ github.event.before }} + GITHUB_NEW_SHA: ${{ github.event.after }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GIT_AUTHOR_NAME: git + GIT_COMMITTER_NAME: git + EMAIL: svn-admin@ruby-lang.org + if: ${{ github.repository == 'ruby/ruby' && github.ref == 'refs/heads/master' && github.event_name == 'push' }} + + - uses: ./.github/actions/slack + with: + SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot + if: ${{ failure() }} From f063427c45ecf35f98efc27fe92a49b035016063 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Tue, 7 Oct 2025 20:56:14 -0700 Subject: [PATCH 3/4] post_push.yml: Skip .github/actions/setup/directories These scripts are made to be fairly portable, so it shouldn't need all these steps to make them work. --- .github/workflows/post_push.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/post_push.yml b/.github/workflows/post_push.yml index 724a67017aa49f..0ddcc2e283619a 100644 --- a/.github/workflows/post_push.yml +++ b/.github/workflows/post_push.yml @@ -39,12 +39,6 @@ jobs: RUBY_GIT_SYNC_PRIVATE_KEY: ${{ secrets.RUBY_GIT_SYNC_PRIVATE_KEY }} if: ${{ github.repository == 'ruby/ruby' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/ruby_')) && github.event_name == 'push' }} - - uses: ./.github/actions/setup/directories - with: - makeup: true - # Skip overwriting MATZBOT_AUTO_UPDATE_TOKEN - checkout: '' # false (ref: https://github.com/actions/runner/issues/2238) - - name: Auto-correct code styles run: | set -x From 000165a51cb845c5af4b735a8ca42994708551af Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Tue, 7 Oct 2025 21:07:54 -0700 Subject: [PATCH 4/4] post_push.yml: Simplify the overall workflow --- .github/workflows/post_push.yml | 46 ++++++++++++++++----------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/.github/workflows/post_push.yml b/.github/workflows/post_push.yml index 0ddcc2e283619a..e252239c3fbf4e 100644 --- a/.github/workflows/post_push.yml +++ b/.github/workflows/post_push.yml @@ -1,21 +1,32 @@ name: Post-push -on: push +on: + push: + branches: + - master + - 'ruby_*_*' jobs: hooks: name: Post-push hooks - - permissions: - contents: write # for Git to git push - runs-on: ubuntu-latest - + if: ${{ github.repository == 'ruby/ruby' }} steps: + - name: Sync git.ruby-lang.org + run: | + mkdir -p ~/.ssh + echo "$RUBY_GIT_SYNC_PRIVATE_KEY" > ~/.ssh/id_ed25519 + chmod 600 ~/.ssh/id_ed25519 + ssh-keyscan -t ed25519 git.ruby-lang.org >> ~/.ssh/known_hosts + ssh -i ~/.ssh/id_ed25519 git-sync@git.ruby-lang.org "sudo -u git /home/git/git.ruby-lang.org/bin/update-ruby.sh $GITHUB_REF" + env: + GITHUB_REF: ${{ github.ref }} + RUBY_GIT_SYNC_PRIVATE_KEY: ${{ secrets.RUBY_GIT_SYNC_PRIVATE_KEY }} + if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/ruby_') }} + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: fetch-depth: 500 # for notify-slack-commits - token: ${{ (github.repository == 'ruby/ruby' && !startsWith(github.event_name, 'pull')) && secrets.MATZBOT_AUTO_UPDATE_TOKEN || secrets.GITHUB_TOKEN }} + token: ${{ secrets.MATZBOT_AUTO_UPDATE_TOKEN }} - # Run this step first (even before `make up` in the next step) to make the notification available before any other failure - name: Notify commit to Slack run: ruby tool/notify-slack-commits.rb "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA" refs/heads/master env: @@ -24,20 +35,7 @@ jobs: SLACK_WEBHOOK_URL_ALERTS: ${{ secrets.SLACK_WEBHOOK_URL_ALERTS }} SLACK_WEBHOOK_URL_COMMITS: ${{ secrets.SLACK_WEBHOOK_URL_COMMITS }} SLACK_WEBHOOK_URL_RUBY_JP: ${{ secrets.SLACK_WEBHOOK_URL_RUBY_JP }} - if: ${{ github.repository == 'ruby/ruby' && github.ref == 'refs/heads/master' && github.event_name == 'push' }} - continue-on-error: true # The next auto-style should always run - - - name: Sync git.ruby-lang.org - run: | - mkdir -p ~/.ssh - echo "$RUBY_GIT_SYNC_PRIVATE_KEY" > ~/.ssh/id_ed25519 - chmod 600 ~/.ssh/id_ed25519 - ssh-keyscan -t ed25519 git.ruby-lang.org >> ~/.ssh/known_hosts - ssh -i ~/.ssh/id_ed25519 git-sync@git.ruby-lang.org "sudo -u git /home/git/git.ruby-lang.org/bin/update-ruby.sh $GITHUB_REF" - env: - GITHUB_REF: ${{ github.ref }} - RUBY_GIT_SYNC_PRIVATE_KEY: ${{ secrets.RUBY_GIT_SYNC_PRIVATE_KEY }} - if: ${{ github.repository == 'ruby/ruby' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/ruby_')) && github.event_name == 'push' }} + if: ${{ github.ref == 'refs/heads/master' }} - name: Auto-correct code styles run: | @@ -49,7 +47,7 @@ jobs: GIT_AUTHOR_NAME: git GIT_COMMITTER_NAME: git EMAIL: svn-admin@ruby-lang.org - if: ${{ github.repository == 'ruby/ruby' && github.ref == 'refs/heads/master' && github.event_name == 'push' }} + if: ${{ github.ref == 'refs/heads/master' }} - name: Push PR notes to GitHub run: ruby tool/notes-github-pr.rb "$(pwd)/.git" "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA" refs/heads/master @@ -60,7 +58,7 @@ jobs: GIT_AUTHOR_NAME: git GIT_COMMITTER_NAME: git EMAIL: svn-admin@ruby-lang.org - if: ${{ github.repository == 'ruby/ruby' && github.ref == 'refs/heads/master' && github.event_name == 'push' }} + if: ${{ github.ref == 'refs/heads/master' }} - uses: ./.github/actions/slack with: