Skip to content

Commit d4f0c23

Browse files
committed
fixup! tools: add workflow to add author ready
1 parent 19c9e77 commit d4f0c23

File tree

1 file changed

+36
-7
lines changed

1 file changed

+36
-7
lines changed

.github/workflows/label-pr.yml

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,28 @@ on:
66
pull_request_review:
77
types: [submitted]
88

9-
permissions:
10-
contents: read
9+
permissions: {}
1110

1211
jobs:
1312
label:
1413
runs-on: ubuntu-latest
14+
if: github.event_name != 'pull_request_review'
1515

1616
steps:
1717
- uses: nodejs/node-pr-labeler@d4cf1b8b9f23189c37917000e5e17e796c770a6b # v1
18-
if: github.event_name != 'pull_request_review'
1918
with:
2019
repo-token: ${{ secrets.GH_USER_TOKEN }}
2120
configuration-path: .github/label-pr-config.yml
21+
22+
author_ready:
23+
runs-on: ubuntu-latest
24+
if: github.event_name == 'pull_request_review'
25+
permissions:
26+
issues: write
27+
steps:
2228
- name: Add 'Author ready' label
23-
if: github.event_name == 'pull_request_review'
2429
run: |
25-
gh pr view "$PR_URL" --json reviewDecision,statusCheckRollup,mergeable,labels --jq '
30+
gh pr view "$PR_URL" --json review,statusCheckRollup,mergeable,labels --jq '
2631
if .mergeable == "MERGEABLE" and
2732
.reviewDecision == "APPROVED" and
2833
(.statusCheckRollup | all(.conclusion != "FAILURE")) and
@@ -34,7 +39,31 @@ jobs:
3439
failedChecks: .statusCheckRollup | map(select(.conclusion == "FAILURE")),
3540
mergeable,
3641
reviewDecision,
37-
}' || gh pr edit "$PR_URL" --add-label 'author ready'
42+
}' \
43+
|| gh api graphql -f query='
44+
query($owner: String!, $repo: String!, $pr: Int!) {
45+
repository(owner: $owner, name: $repo) {
46+
pullRequest(number: $pr) {
47+
reviewThreads(first: 100) {
48+
nodes {
49+
isResolved
50+
comments(first: 1) {
51+
nodes {
52+
body
53+
author { login }
54+
}
55+
}
56+
}
57+
}
58+
}
59+
}
60+
}' -F "owner=$OWNER" -F "repo=$REPO" -F "pr=$PR_NUMBER" --jq '
61+
.data.repository.pullRequest.reviewThreads.nodes | if all(.isResolved)
62+
then
63+
halt_error
64+
end
65+
' \
66+
|| gh pr edit "$PR_URL" --add-label 'author ready'
3867
env:
39-
GH_TOKEN: ${{ secrets.GH_USER_TOKEN }}
68+
GH_TOKEN: ${{ github.token }}
4069
PR_URL: ${{ github.event.pull_request.html_url }}

0 commit comments

Comments
 (0)