Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 53 additions & 2 deletions .github/workflows/label-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,67 @@ name: Label PRs
on:
pull_request_target:
types: [opened]
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
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 }}
Loading