fix: track PR template auto-close with label (#27042)

* fix: track PR template auto-close with label

* fix: format
This commit is contained in:
bo0tzz
2026-03-19 17:42:29 +01:00
committed by GitHub
parent 044257531e
commit bc2439883a

View File

@@ -6,6 +6,9 @@ on:
permissions: {} permissions: {}
env:
LABEL_ID: 'LA_kwDOGyI-8M8AAAACcAeOfg' # auto-closed:template
jobs: jobs:
parse: parse:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -46,9 +49,10 @@ jobs:
run: | run: |
gh api graphql \ gh api graphql \
-f prId="$NODE_ID" \ -f prId="$NODE_ID" \
-f labelId="$LABEL_ID" \
-f body="This PR has been automatically closed as the description doesn't follow our template. After you edit it to match the template, the PR will automatically be reopened." \ -f body="This PR has been automatically closed as the description doesn't follow our template. After you edit it to match the template, the PR will automatically be reopened." \
-f query=' -f query='
mutation CommentAndClosePR($prId: ID!, $body: String!) { mutation CommentAndClosePR($prId: ID!, $body: String!, $labelId: ID!) {
addComment(input: { addComment(input: {
subjectId: $prId, subjectId: $prId,
body: $body body: $body
@@ -60,21 +64,34 @@ jobs:
}) { }) {
__typename __typename
} }
addLabelsToLabelable(input: {
labelableId: $prId,
labelIds: [$labelId]
}) {
__typename
}
}' }'
- name: Reopen PR (sections now present, PR closed) - name: Reopen PR (sections now present, PR was auto-closed)
if: ${{ needs.parse.outputs.uses_template == 'true' && github.event.pull_request.state == 'closed' }} if: ${{ needs.parse.outputs.uses_template == 'true' && github.event.pull_request.state == 'closed' && contains(github.event.pull_request.labels.*.node_id, env.LABEL_ID) }}
env: env:
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ github.token }}
NODE_ID: ${{ github.event.pull_request.node_id }} NODE_ID: ${{ github.event.pull_request.node_id }}
run: | run: |
gh api graphql \ gh api graphql \
-f prId="$NODE_ID" \ -f prId="$NODE_ID" \
-f labelId="$LABEL_ID" \
-f query=' -f query='
mutation ReopenPR($prId: ID!) { mutation ReopenPR($prId: ID!, $labelId: ID!) {
reopenPullRequest(input: { reopenPullRequest(input: {
pullRequestId: $prId pullRequestId: $prId
}) { }) {
__typename __typename
} }
removeLabelsFromLabelable(input: {
labelableId: $prId,
labelIds: [$labelId]
}) {
__typename
}
}' }'