1
1
name : wiby
2
2
3
3
on :
4
- issue_comment :
5
- types : [ created ]
4
+ pull_request_target :
5
+ types : [ labeled ]
6
6
7
7
env :
8
8
WIBY_CHECK_NAME : " wiby"
9
9
WIBY_NODE_VERSION : 14
10
10
11
11
jobs :
12
12
13
- permissions :
13
+ status :
14
14
15
15
runs-on : ubuntu-latest
16
16
17
- if : ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, 'wiby ') && (github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'COLLABORATOR') }}
17
+ if : ${{ github.event.label.name == 'wiby test' }}
18
+
19
+ outputs :
20
+ in_progress : ${{ steps.checks_by_status.outputs.in_progress }}
21
+ queued : ${{ steps.checks_by_status.outputs.queued }}
22
+ completed : ${{ steps.checks_by_status.outputs.completed }}
18
23
19
24
steps :
20
- - run : ' echo "Author association: ${{ github.event.comment.author_association }}"'
25
+ - name : Get status
26
+
27
+ with :
28
+ route : GET /repos/:repository/commits/:ref/check-runs
29
+ repository : ${{ github.event.repository.full_name }}
30
+ ref : ${{ github.event.pull_request.head.sha }}
31
+ mediaType : |
32
+ previews:
33
+ - antiope
34
+ env :
35
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
36
+ id : pr_status
37
+
38
+ - name : Count wiby status check by their status
39
+ run : |
40
+ jq -r '.check_runs | map(select(.name=="wiby")) | group_by(.status) | map("::set-output name=" + .[0].status + "::" + (length | tostring)) | join("\n")' << EOF
41
+ ${{ steps.pr_status.outputs.data }}
42
+ EOF
43
+ id : checks_by_status
21
44
22
45
test :
23
46
24
47
runs-on : ubuntu-latest
25
48
26
- needs : permissions
49
+ needs : status
27
50
28
- if : ${{ startsWith(github.event.comment.body, 'wiby test') }}
51
+ if : ${{ !needs.status.outputs.in_progress && !needs.status.outputs.queued }}
29
52
30
53
steps :
31
54
32
- - name : Load PR
33
-
34
- with :
35
- route : ${{ github.event.issue.pull_request.url }}
36
- env :
37
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
38
- id : load_pr
39
-
40
- - name : Get PR information
41
- run : |
42
- echo "::set-output name=branch::${{ fromJson(steps.load_pr.outputs.data).head.ref }}"
43
- echo "::set-output name=head_sha::${{ fromJson(steps.load_pr.outputs.data).head.sha }}"
44
- echo "::set-output name=repo_name::${{ fromJson(steps.load_pr.outputs.data).base.repo.full_name }}"
45
- echo "::set-output name=repo_url::${{ fromJson(steps.load_pr.outputs.data).base.repo.html_url }}"
46
- id : pr
47
-
48
55
- name : Set "queued" status
49
56
50
57
with :
51
58
route : POST /repos/:repository/check-runs
52
- repository : ${{ steps.pr.outputs.repo_name }}
59
+ repository : ${{ github.event.repository.full_name }}
53
60
mediaType : |
54
61
previews:
55
62
- antiope
56
63
name : ${{ env.WIBY_CHECK_NAME }}
57
- details_url : " ${{ steps.pr.outputs.repo_url }}/actions/runs/${{ github.run_id }}"
58
- head_sha : ${{ steps.pr.outputs.head_sha }}
64
+ head_sha : ${{ github.event.pull_request.head.sha }}
59
65
status : " queued"
60
66
env :
61
67
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
64
70
uses : actions/checkout@v2
65
71
with :
66
72
token : ${{ secrets.GITHUB_TOKEN }}
67
- repository : ${{ steps.pr.outputs.repo_name }}
68
- ref : ${{ steps.pr.outputs.branch }}
73
+ repository : ${{ github.event.repository.full_name }}
74
+ ref : ${{ github.event.pull_request.head.ref }}
69
75
70
76
- name : Prepare Node.js
71
77
uses : actions/setup-node@v2
@@ -89,13 +95,12 @@ jobs:
89
95
if : ${{ failure() }}
90
96
with :
91
97
route : POST /repos/:repository/check-runs
92
- repository : ${{ steps.pr.outputs.repo_name }}
98
+ repository : ${{ github.event.repository.full_name }}
93
99
mediaType : |
94
100
previews:
95
101
- antiope
96
102
name : ${{ env.WIBY_CHECK_NAME }}
97
- details_url : " ${{ steps.pr.outputs.repo_url }}/actions/runs/${{ github.run_id }}"
98
- head_sha : ${{ steps.pr.outputs.head_sha }}
103
+ head_sha : ${{ github.event.pull_request.head.sha }}
99
104
conclusion : " failure"
100
105
env :
101
106
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
@@ -104,49 +109,44 @@ jobs:
104
109
105
110
with :
106
111
route : POST /repos/:repository/check-runs
107
- repository : ${{ steps.pr.outputs.repo_name }}
112
+ repository : ${{ github.event.repository.full_name }}
108
113
mediaType : |
109
114
previews:
110
115
- antiope
111
116
name : ${{ env.WIBY_CHECK_NAME }}
112
- details_url : " ${{ steps.pr.outputs.repo_url }}/actions/runs/${{ github.run_id }}"
113
- head_sha : ${{ steps.pr.outputs.head_sha }}
117
+ head_sha : ${{ github.event.pull_request.head.sha }}
114
118
status : " in_progress"
115
119
env :
116
120
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
117
121
122
+ - name : Clean up the trigger label
123
+ if : ${{ always() }}
124
+
125
+ with :
126
+ route : DELETE /repos/:repository/issues/:issue_number/labels/:label_name
127
+ repository : ${{ github.event.repository.full_name }}
128
+ issue_number : ${{ github.event.pull_request.number }}
129
+ label_name : ${{ github.event.label.name }}
130
+ env :
131
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
132
+
133
+
118
134
result :
119
135
120
136
runs-on : ubuntu-latest
121
137
122
- needs : permissions
138
+ needs : status
123
139
124
- if : ${{ startsWith(github.event.comment.body, 'wiby result') }}
140
+ if : ${{ needs.status.outputs.in_progress }}
125
141
126
142
steps :
127
143
128
- - name : Load PR
129
-
130
- with :
131
- route : ${{ github.event.issue.pull_request.url }}
132
- env :
133
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
134
- id : load_pr
135
-
136
- - name : Get PR information
137
- run : |
138
- echo "::set-output name=branch::${{ fromJson(steps.load_pr.outputs.data).head.ref }}"
139
- echo "::set-output name=head_sha::${{ fromJson(steps.load_pr.outputs.data).head.sha }}"
140
- echo "::set-output name=repo_name::${{ fromJson(steps.load_pr.outputs.data).base.repo.full_name }}"
141
- echo "::set-output name=repo_url::${{ fromJson(steps.load_pr.outputs.data).base.repo.html_url }}"
142
- id : pr
143
-
144
144
- name : Checkout PR Branch
145
145
uses : actions/checkout@v2
146
146
with :
147
147
token : ${{ secrets.GITHUB_TOKEN }}
148
- repository : ${{ steps.pr.outputs.repo_name }}
149
- ref : ${{ steps.pr.outputs.branch }}
148
+ repository : ${{ github.event.repository.full_name }}
149
+ ref : ${{ github.event.pull_request.head.ref }}
150
150
151
151
- name : Prepare Node.js
152
152
uses : actions/setup-node@v2
@@ -162,7 +162,7 @@ jobs:
162
162
WIBY_RESULT_CODE=$1
163
163
164
164
if [ ${WIBY_RESULT_CODE} -eq 64 ]; then
165
- echo "` wiby` exited with code 64 - results are still pending"
165
+ echo "wiby exited with code 64 - results are still pending"
166
166
exit
167
167
else
168
168
echo "::set-output name=wiby_conclusion::failure"
@@ -191,13 +191,12 @@ jobs:
191
191
if : ${{ failure() }}
192
192
with :
193
193
route : POST /repos/:repository/check-runs
194
- repository : ${{ steps.pr.outputs.repo_name }}
194
+ repository : ${{ github.event.repository.full_name }}
195
195
mediaType : |
196
196
previews:
197
197
- antiope
198
198
name : ${{ env.WIBY_CHECK_NAME }}
199
- details_url : " ${{ steps.pr.outputs.repo_url }}/actions/runs/${{ github.run_id }}"
200
- head_sha : ${{ steps.pr.outputs.head_sha }}
199
+ head_sha : ${{ github.event.pull_request.head.sha }}
201
200
conclusion : " failure"
202
201
env :
203
202
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
@@ -207,13 +206,23 @@ jobs:
207
206
if : ${{ steps.wiby_result.outputs.wiby_conclusion != '' }}
208
207
with :
209
208
route : POST /repos/:repository/check-runs
210
- repository : ${{ steps.pr.outputs.repo_name }}
209
+ repository : ${{ github.event.repository.full_name }}
211
210
mediaType : |
212
211
previews:
213
212
- antiope
214
213
name : ${{ env.WIBY_CHECK_NAME }}
215
- details_url : " ${{ steps.pr.outputs.repo_url }}/actions/runs/${{ github.run_id }}"
216
- head_sha : ${{ steps.pr.outputs.head_sha }}
214
+ head_sha : ${{ github.event.pull_request.head.sha }}
217
215
conclusion : ${{ steps.wiby_result.outputs.wiby_conclusion }}
218
216
env :
219
217
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
218
+
219
+ - name : Clean up the trigger label
220
+ if : ${{ always() }}
221
+
222
+ with :
223
+ route : DELETE /repos/:repository/issues/:issue_number/labels/:label_name
224
+ repository : ${{ github.event.repository.full_name }}
225
+ issue_number : ${{ github.event.pull_request.number }}
226
+ label_name : ${{ github.event.label.name }}
227
+ env :
228
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments