|
6 | 6 | pull_request_review: |
7 | 7 | types: [submitted] |
8 | 8 |
|
9 | | -permissions: |
10 | | - contents: read |
| 9 | +permissions: {} |
11 | 10 |
|
12 | 11 | jobs: |
13 | 12 | label: |
14 | 13 | runs-on: ubuntu-latest |
| 14 | + if: github.event_name != 'pull_request_review' |
15 | 15 |
|
16 | 16 | steps: |
17 | 17 | - uses: nodejs/node-pr-labeler@d4cf1b8b9f23189c37917000e5e17e796c770a6b # v1 |
18 | | - if: github.event_name != 'pull_request_review' |
19 | 18 | with: |
20 | 19 | repo-token: ${{ secrets.GH_USER_TOKEN }} |
21 | 20 | 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: |
22 | 28 | - name: Add 'Author ready' label |
23 | | - if: github.event_name == 'pull_request_review' |
24 | 29 | 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 ' |
26 | 31 | if .mergeable == "MERGEABLE" and |
27 | 32 | .reviewDecision == "APPROVED" and |
28 | 33 | (.statusCheckRollup | all(.conclusion != "FAILURE")) and |
|
34 | 39 | failedChecks: .statusCheckRollup | map(select(.conclusion == "FAILURE")), |
35 | 40 | mergeable, |
36 | 41 | 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' |
38 | 67 | env: |
39 | | - GH_TOKEN: ${{ secrets.GH_USER_TOKEN }} |
| 68 | + GH_TOKEN: ${{ github.token }} |
40 | 69 | PR_URL: ${{ github.event.pull_request.html_url }} |
0 commit comments