|
| 1 | +name: Sync default gems |
| 2 | +on: |
| 3 | + # Main use of this workflow. Called by default gem repositories by API. |
| 4 | + repository_dispatch: |
| 5 | + types: |
| 6 | + - sync_default_gems |
| 7 | + |
| 8 | + # Web UI dispatch for testing and manual operations. |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + gem: |
| 12 | + required: true |
| 13 | + description: 'Name of the gem to be synchronized' |
| 14 | + type: string |
| 15 | + before: |
| 16 | + required: true |
| 17 | + description: 'Gem commit SHA before sync' |
| 18 | + type: string |
| 19 | + after: |
| 20 | + required: true |
| 21 | + description: 'Gem commit SHA after sync' |
| 22 | + type: string |
| 23 | + |
| 24 | +jobs: |
| 25 | + sync_default_gems: |
| 26 | + name: Update default gems list |
| 27 | + |
| 28 | + permissions: |
| 29 | + contents: write # for Git to git push |
| 30 | + |
| 31 | + runs-on: ubuntu-latest |
| 32 | + |
| 33 | + if: ${{ github.repository == 'ruby/ruby' }} |
| 34 | + |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 37 | + name: Check out ruby/ruby |
| 38 | + with: |
| 39 | + token: ${{ (github.repository == 'ruby/ruby' && secrets.MATZBOT_AUTO_UPDATE_TOKEN || secrets.GITHUB_TOKEN }} |
| 40 | + |
| 41 | + - name: Run tool/sync_default_gems.rb |
| 42 | + run: ruby tool/sync_default_gems.rb "${gem_name}" "${gem_before}..${gem_after}" |
| 43 | + env: |
| 44 | + gem_name: ${{ github.event.client_payload.gem || github.event.inputs.gem }} |
| 45 | + gem_before: ${{ github.event.client_payload.before || github.event.inputs.before }} |
| 46 | + gem_after: ${{ github.event.client_payload.after || github.event.inputs.after }} |
| 47 | + |
| 48 | + - name: Check diffs |
| 49 | + id: diff |
| 50 | + run: | |
| 51 | + git diff --color --no-ext-diff --ignore-submodules --exit-code || |
| 52 | + echo update=true >> $GITHUB_OUTPUT |
| 53 | +
|
| 54 | + - name: Push |
| 55 | + run: | |
| 56 | + git pull --ff-only origin ${GITHUB_REF#refs/heads/} |
| 57 | + git push origin ${GITHUB_REF#refs/heads/} |
| 58 | + env: |
| 59 | + EMAIL: svn-admin@ruby-lang.org |
| 60 | + GIT_AUTHOR_NAME: git |
| 61 | + GIT_COMMITTER_NAME: git |
| 62 | + if: ${{ steps.diff.outputs.update }} |
| 63 | + |
| 64 | + - uses: ./.github/actions/slack |
| 65 | + with: |
| 66 | + SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot |
| 67 | + if: ${{ failure() }} |
0 commit comments