File tree 1 file changed +54
-0
lines changed
1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Agenda auto-merge
2
+
3
+ on :
4
+ pull_request_target :
5
+ types : [synchronize, opened, reopened]
6
+
7
+ permissions :
8
+ contents : write
9
+ pull-requests : read
10
+ checks : read
11
+
12
+ jobs :
13
+ validate-and-merge :
14
+ if : ${{ github.event.pull_request.base.ref == 'main' }}
15
+ runs-on : ubuntu-latest
16
+
17
+ steps :
18
+ # SECURITY: it's critical we do not check out the source pull request!
19
+ - name : Checkout the main branch
20
+ uses : actions/checkout@v3
21
+ with :
22
+ ref : main
23
+
24
+ # We need wgutils to be installed
25
+ - run : yarn install
26
+
27
+ - name : Wait for checks to pass
28
+ env :
29
+ GH_TOKEN : ${{ github.token }}
30
+ run : |
31
+ # Give 15 seconds for any checks to register
32
+ sleep 15
33
+
34
+ # Wait for checks to pass
35
+ gh pr checks ${{ github.event.pull_request.number }} --fail-fast --watch --required 2>&1 || true
36
+ # Now get the result in JSON
37
+ CHECKS_OUTPUT="$(gh pr checks ${{ github.event.pull_request.number }} --required --json bucket --jq 'map(.bucket == "pass") | all' 2>&1 || true)"
38
+
39
+ if echo "$CHECKS_OUTPUT" | grep -q "no required checks reported"; then
40
+ echo "Not required: $CHECKS_OUTPUT"
41
+ elif [[ "$CHECKS_OUTPUT" == "true" ]]; then
42
+ echo "$CHECKS_OUTPUT"
43
+ else
44
+ echo "PR state failed? $CHECKS_OUTPUT"
45
+ exit 1
46
+ fi
47
+
48
+ - name : Automerge if wgutils approves
49
+ env :
50
+ GH_TOKEN : ${{ github.token }}
51
+ run : |
52
+ if yarn wgutils can-automerge "${{ github.event.pull_request.number }}" "${{ github.event.pull_request.head.sha }}"; then
53
+ gh pr merge "${{ github.event.pull_request.number }}" --squash --auto --match-head-commit "${{ github.event.pull_request.head.sha }}"
54
+ fi
You can’t perform that action at this time.
0 commit comments