1- name : Lock Release Pull Request
1+ name : Toggle Release Lock
22
33on :
4+ release :
5+ types : [released]
46 workflow_dispatch :
57 inputs :
68 action :
1315
1416jobs :
1517 lock :
16- name : Toggle Release Lock
18+ if : ${{ github.event.inputs.action == 'lock' }}
19+ name : Lock the release
1720 runs-on : ubuntu-latest
1821 steps :
1922 - name : Get App Token
@@ -24,36 +27,52 @@ jobs:
2427 owner : primer
2528 repositories : react
2629 private-key : ${{ secrets.PRIMER_APP_PRIVATE_KEY_SHARED }}
27- - name : Toggle Rule > Release Conductor
30+ - name : Toggle rulesets
2831 run : |
29- enforcement=$([ "${{ github.event.inputs.action }}" == "lock" ] && echo "active" || echo "disabled")
32+ # Allow react-release-conductor to bypass merge queue
33+ gh api \
34+ --method PUT \
35+ -H "Accept: application/vnd.github+json" \
36+ -H "X-GitHub-Api-Version: 2022-11-28" \
37+ /repos/primer/react/rulesets/4089335 \
38+ -F "bypass_actors[][actor_id]=12276524" \
39+ -f "bypass_actors[][actor_type]=Team" \
40+ -f "bypass_actors[][bypass_mode]=always"
41+ gh api \
42+ --method PUT \
43+ -H "Accept: application/vnd.github+json" \
44+ -H "X-GitHub-Api-Version: 2022-11-28" \
45+ /repos/primer/react/rulesets/3801256 \
46+ -f "enforcement=active"
47+ env :
48+ GITHUB_TOKEN : ${{ steps.app-token.outputs.token }}
49+
50+ unlock :
51+ if : ${{ github.event.inputs.action == 'unlock' || github.event.action == 'released' }}
52+ name : Unlock the release
53+ runs-on : ubuntu-latest
54+ steps :
55+ - name : Get App Token
56+ uses : actions/create-github-app-token@21cfef2b496dd8ef5b904c159339626a10ad380e
57+ id : app-token
58+ with :
59+ app-id : ${{ vars.PRIMER_APP_ID_SHARED }}
60+ owner : primer
61+ repositories : react
62+ private-key : ${{ secrets.PRIMER_APP_PRIVATE_KEY_SHARED }}
63+ - name : Toggle rulesets
64+ run : |
65+ gh api \
66+ --method PUT \
67+ -H "Accept: application/vnd.github+json" \
68+ -H "X-GitHub-Api-Version: 2022-11-28" \
69+ /repos/primer/react/rulesets/4089335 \
70+ -F "bypass_actors[]"
3071 gh api \
3172 --method PUT \
3273 -H "Accept: application/vnd.github+json" \
3374 -H "X-GitHub-Api-Version: 2022-11-28" \
3475 /repos/primer/react/rulesets/3801256 \
35- -f "enforcement=${enforcement} "
76+ -f "enforcement=disabled "
3677 env :
3778 GITHUB_TOKEN : ${{ steps.app-token.outputs.token }}
38- # - name: Toggle Rule > Update Before Merging
39- # run: |
40- # enforcement=$([ "${{ github.event.inputs.action }}" == "lock" ] && echo "active" || echo "disabled")
41- # gh api \
42- # --method PUT \
43- # -H "Accept: application/vnd.github+json" \
44- # -H "X-GitHub-Api-Version: 2022-11-28" \
45- # /repos/primer/react/rulesets/4089341 \
46- # -f "enforcement=${enforcement}"
47- # env:
48- # GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
49- # - name: Toggle Rule > Merge Queue
50- # run: |
51- # enforcement=$([ "${{ github.event.inputs.action }}" == "lock" ] && echo "disabled" || echo "active")
52- # gh api \
53- # --method PUT \
54- # -H "Accept: application/vnd.github+json" \
55- # -H "X-GitHub-Api-Version: 2022-11-28" \
56- # /repos/primer/react/rulesets/4089335 \
57- # -f "enforcement=${enforcement}"
58- # env:
59- # GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
0 commit comments