8
8
types :
9
9
- completed
10
10
11
+ concurrency :
12
+ group : pr-${{ github.event.workflow_run.pull_requests[0].number }}
13
+ cancel-in-progress : true
14
+
15
+
11
16
jobs :
12
17
# Pull requests are valid if:
13
18
# - they match the sha of the workflow run head commit
16
21
test-pr :
17
22
name : " Test if pull request is valid"
18
23
runs-on : ubuntu-latest
19
- if : >
20
- github.event.workflow_run.event == 'pull_request' &&
24
+ if : >
25
+ github.event.workflow_run.event == 'pull_request' &&
21
26
github.event.workflow_run.conclusion == 'success'
22
27
outputs :
23
28
is_valid : ${{ steps.check-pr.outputs.VALID }}
58
63
with :
59
64
pr : ${{ steps.get-pr.outputs.NUM }}
60
65
sha : ${{ github.event.workflow_run.head_sha }}
66
+ headroom : 3 # if it's within the last three commits, we can keep going, because it's likely rapid-fire
61
67
invalid : ${{ fromJSON(steps.hash.outputs.json)[github.repository] }}
62
68
fail_on_error : true
63
69
72
78
if : ${{ needs.test-pr.outputs.is_valid == 'true' }}
73
79
env :
74
80
NR : ${{ needs.test-pr.outputs.number }}
81
+ permissions :
82
+ contents : write
75
83
steps :
76
84
- name : ' Checkout md outputs'
77
85
uses : actions/checkout@v3
98
106
git config --local user.name "GitHub Actions"
99
107
CURR_HEAD=$(git rev-parse HEAD)
100
108
git checkout --orphan md-outputs-PR-${NR}
101
- git add -A
109
+ git add -A
102
110
git commit -m "source commit: ${CURR_HEAD}"
103
- ls -A | grep -v '^.git$' | xargs rm -r
111
+ ls -A | grep -v '^.git$' | xargs -I _ rm -r '_'
104
112
cd ..
105
113
unzip -o -d built built.zip
106
114
cd built
@@ -116,14 +124,16 @@ jobs:
116
124
if : ${{ needs.test-pr.outputs.is_valid == 'true' }}
117
125
env :
118
126
NR : ${{ needs.test-pr.outputs.number }}
127
+ permissions :
128
+ pull-requests : write
119
129
steps :
120
130
- name : ' Download comment artifact'
121
131
id : dl
122
132
uses : carpentries/actions/download-workflow-artifact@main
123
133
with :
124
134
run : ${{ github.event.workflow_run.id }}
125
135
name : ' diff'
126
-
136
+
127
137
- if : ${{ steps.dl.outputs.success == 'true' }}
128
138
run : unzip ${{ github.workspace }}/diff.zip
129
139
@@ -132,7 +142,7 @@ jobs:
132
142
if : ${{ steps.dl.outputs.success == 'true' }}
133
143
uses : carpentries/actions/comment-diff@main
134
144
with :
135
- pr : ${{ env.NR }}
145
+ pr : ${{ env.NR }}
136
146
path : ${{ github.workspace }}/diff.md
137
147
138
148
# Comment if the PR is open and matches the SHA, but the workflow files have
@@ -145,6 +155,8 @@ jobs:
145
155
env :
146
156
NR : ${{ github.event.workflow_run.pull_requests[0].number }}
147
157
body : ${{ needs.test-pr.outputs.msg }}
158
+ permissions :
159
+ pull-requests : write
148
160
steps :
149
161
- name : ' Check for spoofing'
150
162
id : dl
0 commit comments