Skip to content

tools: add workflow to add author ready #14464

tools: add workflow to add author ready

tools: add workflow to add author ready #14464

Workflow file for this run

name: Label PRs
on:
pull_request_target:
types: [opened]
pull_request_review:
types: [submitted]
permissions: {}
jobs:
label:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request_review'
steps:
- uses: nodejs/node-pr-labeler@d4cf1b8b9f23189c37917000e5e17e796c770a6b # v1
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
run: |
gh pr view "$PR_URL" --json review,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 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: ${{ github.token }}
PR_URL: ${{ github.event.pull_request.html_url }}