Skip to content

Commit 0e425f5

Browse files
committed
feat: use wiby test label as a trigger
1 parent 9123ee7 commit 0e425f5

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

.github/workflows/wiby.yaml

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,61 @@
11
name: wiby
22

33
on:
4-
issue_comment:
5-
types: [ created ]
4+
pull_request:
5+
types: [ labeled ]
66

77
env:
88
WIBY_CHECK_NAME: "wiby"
99
WIBY_NODE_VERSION: 14
1010

1111
jobs:
1212

13-
permissions:
13+
status:
1414

1515
runs-on: ubuntu-latest
1616

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 }}
1823

1924
steps:
20-
- run: 'echo "Author association: ${{ github.event.comment.author_association }}"'
25+
- name: Get status
26+
uses: octokit/[email protected]
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
2144

2245
test:
2346

2447
runs-on: ubuntu-latest
2548

26-
needs: permissions
49+
needs: status
2750

28-
if: ${{ startsWith(github.event.comment.body, 'wiby test') }}
51+
if: ${{ !needs.status.outputs.in_progress && !needs.status.outputs.queued }}
2952

3053
steps:
3154

3255
- name: Load PR
3356
uses: octokit/[email protected]
3457
with:
35-
route: ${{ github.event.issue.pull_request.url }}
58+
route: ${{ github.event.pull_request.url }}
3659
env:
3760
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3861
id: load_pr
@@ -119,9 +142,9 @@ jobs:
119142

120143
runs-on: ubuntu-latest
121144

122-
needs: permissions
145+
needs: status
123146

124-
if: ${{ startsWith(github.event.comment.body, 'wiby result') }}
147+
if: ${{ needs.status.outputs.in_progress }}
125148

126149
steps:
127150

0 commit comments

Comments
 (0)