From 19c9e77f2704806992d1d093e59f33d062d0ffec Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sun, 2 Nov 2025 20:46:07 +0100 Subject: [PATCH 1/2] tools: add workflow to add `author ready` --- .github/workflows/label-pr.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/label-pr.yml b/.github/workflows/label-pr.yml index 95fdd42a4c700a..b4777e54a2d444 100644 --- a/.github/workflows/label-pr.yml +++ b/.github/workflows/label-pr.yml @@ -3,6 +3,8 @@ name: Label PRs on: pull_request_target: types: [opened] + pull_request_review: + types: [submitted] permissions: contents: read @@ -13,6 +15,26 @@ jobs: steps: - uses: nodejs/node-pr-labeler@d4cf1b8b9f23189c37917000e5e17e796c770a6b # v1 + if: github.event_name != 'pull_request_review' with: repo-token: ${{ secrets.GH_USER_TOKEN }} configuration-path: .github/label-pr-config.yml + - name: Add 'Author ready' label + if: github.event_name == 'pull_request_review' + run: | + gh pr view "$PR_URL" --json reviewDecision,statusCheckRollup,mergeable,labels --jq ' + if .mergeable == "MERGEABLE" and + .reviewDecision == "APPROVED" and + (.statusCheckRollup | all(.conclusion != "FAILURE")) and + ((.labels | all(.name != "needs-ci" and .name != "author ready")) or (.labels | any(.name == "request-ci"))) + then + halt_error + end | { + labels: .labels | map(.name), + failedChecks: .statusCheckRollup | map(select(.conclusion == "FAILURE")), + mergeable, + reviewDecision, + }' || gh pr edit "$PR_URL" --add-label 'author ready' + env: + GH_TOKEN: ${{ secrets.GH_USER_TOKEN }} + PR_URL: ${{ github.event.pull_request.html_url }} From d4f0c23c87fa5ffe341669a9ce83283654faed29 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 3 Nov 2025 19:17:30 +0100 Subject: [PATCH 2/2] fixup! tools: add workflow to add `author ready` --- .github/workflows/label-pr.yml | 43 ++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/.github/workflows/label-pr.yml b/.github/workflows/label-pr.yml index b4777e54a2d444..f0034558f5897e 100644 --- a/.github/workflows/label-pr.yml +++ b/.github/workflows/label-pr.yml @@ -6,23 +6,28 @@ on: pull_request_review: types: [submitted] -permissions: - contents: read +permissions: {} jobs: label: runs-on: ubuntu-latest + if: github.event_name != 'pull_request_review' steps: - uses: nodejs/node-pr-labeler@d4cf1b8b9f23189c37917000e5e17e796c770a6b # v1 - if: github.event_name != 'pull_request_review' with: repo-token: ${{ secrets.GH_USER_TOKEN }} configuration-path: .github/label-pr-config.yml + + author_ready: + runs-on: ubuntu-latest + if: github.event_name == 'pull_request_review' + permissions: + issues: write + steps: - name: Add 'Author ready' label - if: github.event_name == 'pull_request_review' run: | - gh pr view "$PR_URL" --json reviewDecision,statusCheckRollup,mergeable,labels --jq ' + gh pr view "$PR_URL" --json review,statusCheckRollup,mergeable,labels --jq ' if .mergeable == "MERGEABLE" and .reviewDecision == "APPROVED" and (.statusCheckRollup | all(.conclusion != "FAILURE")) and @@ -34,7 +39,31 @@ jobs: failedChecks: .statusCheckRollup | map(select(.conclusion == "FAILURE")), mergeable, reviewDecision, - }' || gh pr edit "$PR_URL" --add-label 'author ready' + }' \ + || gh api graphql -f query=' + query($owner: String!, $repo: String!, $pr: Int!) { + repository(owner: $owner, name: $repo) { + pullRequest(number: $pr) { + reviewThreads(first: 100) { + nodes { + isResolved + comments(first: 1) { + nodes { + body + author { login } + } + } + } + } + } + } + }' -F "owner=$OWNER" -F "repo=$REPO" -F "pr=$PR_NUMBER" --jq ' + .data.repository.pullRequest.reviewThreads.nodes | if all(.isResolved) + then + halt_error + end + ' \ + || gh pr edit "$PR_URL" --add-label 'author ready' env: - GH_TOKEN: ${{ secrets.GH_USER_TOKEN }} + GH_TOKEN: ${{ github.token }} PR_URL: ${{ github.event.pull_request.html_url }}