Skip to content

Commit 9910dc2

Browse files
authored
fix(ci): detect issues closed by merged PRs via cross-reference (#8)
The previous logic checked for commit_id on the closed event, but GitHub doesn't set this when "Closes #X" is in the PR body. Now checks for cross-referenced events from merged PRs instead.
1 parent f55f6dc commit 9910dc2

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

.github/workflows/contributors.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,19 @@ jobs:
2020
# Fetch code contributors (exclude bots)
2121
code_contributors=$(gh api repos/${{ github.repository }}/contributors --paginate --jq '.[] | select(.type != "Bot") | select(.login | test("\\[bot\\]$") | not) | .login')
2222
23-
# Fetch closed issues and check if they were closed by a PR
23+
# Fetch closed issues and check if they were closed by a merged PR
2424
issue_authors=""
2525
closed_issues=$(gh api repos/${{ github.repository }}/issues --paginate -q '.[] | select(.state == "closed") | select(.pull_request == null) | {number, login: .user.login}')
2626
2727
for row in $(echo "$closed_issues" | jq -c '.'); do
2828
issue_num=$(echo "$row" | jq -r '.number')
2929
login=$(echo "$row" | jq -r '.login')
3030
31-
# Check timeline for closed event with commit (meaning closed by PR)
32-
closed_by_pr=$(gh api repos/${{ github.repository }}/issues/$issue_num/timeline --paginate -q '.[] | select(.event == "closed") | select(.commit_id != null) | .commit_id' | head -1)
31+
# Check timeline for cross-referenced merged PR that closed this issue
32+
closed_by_pr=$(gh api repos/${{ github.repository }}/issues/$issue_num/timeline --jq '
33+
[.[] | select(.event == "cross-referenced") |
34+
select(.source.issue.pull_request.merged_at)] |
35+
.[0].source.issue.number // empty')
3336
3437
if [[ -n "$closed_by_pr" ]]; then
3538
issue_authors="$issue_authors$login"$'\n'

0 commit comments

Comments
 (0)