Skip to content

Commit 19c9e77

Browse files
committed
tools: add workflow to add author ready
1 parent 0de8425 commit 19c9e77

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

.github/workflows/label-pr.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: Label PRs
33
on:
44
pull_request_target:
55
types: [opened]
6+
pull_request_review:
7+
types: [submitted]
68

79
permissions:
810
contents: read
@@ -13,6 +15,26 @@ jobs:
1315

1416
steps:
1517
- uses: nodejs/node-pr-labeler@d4cf1b8b9f23189c37917000e5e17e796c770a6b # v1
18+
if: github.event_name != 'pull_request_review'
1619
with:
1720
repo-token: ${{ secrets.GH_USER_TOKEN }}
1821
configuration-path: .github/label-pr-config.yml
22+
- name: Add 'Author ready' label
23+
if: github.event_name == 'pull_request_review'
24+
run: |
25+
gh pr view "$PR_URL" --json reviewDecision,statusCheckRollup,mergeable,labels --jq '
26+
if .mergeable == "MERGEABLE" and
27+
.reviewDecision == "APPROVED" and
28+
(.statusCheckRollup | all(.conclusion != "FAILURE")) and
29+
((.labels | all(.name != "needs-ci" and .name != "author ready")) or (.labels | any(.name == "request-ci")))
30+
then
31+
halt_error
32+
end | {
33+
labels: .labels | map(.name),
34+
failedChecks: .statusCheckRollup | map(select(.conclusion == "FAILURE")),
35+
mergeable,
36+
reviewDecision,
37+
}' || gh pr edit "$PR_URL" --add-label 'author ready'
38+
env:
39+
GH_TOKEN: ${{ secrets.GH_USER_TOKEN }}
40+
PR_URL: ${{ github.event.pull_request.html_url }}

0 commit comments

Comments
 (0)