summaryrefslogtreecommitdiff
path: root/.github/workflows/sync_default_gems.yml
blob: 3947001ccdf71a99572b4645af16d2ce1db7a653 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Sync default gems

env:
  DEFAULT_GEM_SYNC_ENABLED: true

on:
  workflow_dispatch:
    inputs:
      gem:
        required: true
        description: 'Name of the gem to be synchronized'
        type: string
      before:
        required: true
        description: 'Gem commit SHA before sync'
        type: string
      after:
        required: true
        description: 'Gem commit SHA after sync'
        type: string

jobs:
  sync_default_gems:
    name: Sync default gem ${{ github.event.inputs.gem }}

    permissions:
      contents: write # for Git to git push

    runs-on: ubuntu-latest

    if: ${{ github.repository == 'ruby/ruby' }}

    steps:
      - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
        name: Check out ruby/ruby
        with:
          token: ${{ github.repository == 'ruby/ruby' && secrets.MATZBOT_AUTO_UPDATE_TOKEN || secrets.GITHUB_TOKEN }}

      - uses: ruby/setup-ruby@ab177d40ee5483edb974554986f56b33477e21d0 # v1.265.0
        with:
          ruby-version: '3.4'
          bundler: none

      - name: Run tool/sync_default_gems.rb
        id: sync
        run: |
          ruby_before=$(git rev-parse HEAD)
          set -x
          ruby tool/sync_default_gems.rb "${gem_name}" "${gem_before}..${gem_after}"
          if [[ "$(git rev-parse HEAD)" != "$ruby_before" ]]; then
            echo update=true >> $GITHUB_OUTPUT
          fi
        env:
          gem_name: ${{ github.event.inputs.gem }}
          gem_before: ${{ github.event.inputs.before }}
          gem_after: ${{ github.event.inputs.after }}
          EMAIL: svn-admin@ruby-lang.org
          GIT_AUTHOR_NAME: git
          GIT_COMMITTER_NAME: git

      - name: Push
        run: |
          git pull --rebase origin ${GITHUB_REF#refs/heads/}
          git push origin ${GITHUB_REF#refs/heads/}
        if: ${{ steps.sync.outputs.update && env.DEFAULT_GEM_SYNC_ENABLED == 'true' }}
        env:
          EMAIL: svn-admin@ruby-lang.org
          GIT_AUTHOR_NAME: git
          GIT_COMMITTER_NAME: git

      - uses: ./.github/actions/slack
        with:
          SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
          label: "${{ github.event.inputs.gem }} (<https://github.com/${{ github.event.inputs.gem == 'rubygems' && 'rubygems' || 'ruby' }}/${{ github.event.inputs.gem }}/compare/${{ github.event.inputs.before }}...${{ github.event.inputs.after }}|diff>)"
          event_name: workflow_dispatch
          extra_channel_id: C05FPKAU743 # alerts-sync
        if: ${{ failure() }}