Skip to content

Commit 267b7a0

Browse files
authored
[ci] feat: have pr labeler label for closing issues. (#13548)
feat: have pr labeler label for closing issues.
1 parent 7c88e5f commit 267b7a0

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

.github/workflows/pr_labeler.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,36 @@ jobs:
4141
gh pr edit "$PR_NUMBER" --remove-label "missing-tests" 2>/dev/null || true
4242
fi
4343
44+
fixes-issue:
45+
runs-on: ubuntu-latest
46+
steps:
47+
- name: Check for linked closing issues
48+
env:
49+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
PR_NUMBER: ${{ github.event.pull_request.number }}
51+
REPO: ${{ github.repository }}
52+
run: |
53+
OWNER="${REPO%/*}"
54+
NAME="${REPO#*/}"
55+
COUNT=$(gh api graphql \
56+
-F owner="$OWNER" -F name="$NAME" -F number="$PR_NUMBER" \
57+
-f query='
58+
query($owner: String!, $name: String!, $number: Int!) {
59+
repository(owner: $owner, name: $name) {
60+
pullRequest(number: $number) {
61+
closingIssuesReferences(first: 1) {
62+
totalCount
63+
}
64+
}
65+
}
66+
}' \
67+
--jq '.data.repository.pullRequest.closingIssuesReferences.totalCount')
68+
if [ "${COUNT:-0}" -gt 0 ]; then
69+
gh pr edit "$PR_NUMBER" --repo "$REPO" --add-label "fixes-issue"
70+
else
71+
gh pr edit "$PR_NUMBER" --repo "$REPO" --remove-label "fixes-issue" 2>/dev/null || true
72+
fi
73+
4474
size-label:
4575
runs-on: ubuntu-latest
4676
steps:

0 commit comments

Comments
 (0)