ci: auto-assign PR author, credit author on issue close#4551
Merged
Conversation
Adds .github/workflows/auto-assign.yml which assigns the author of a newly opened or reopened issue/PR as the default assignee. - issues: assigns the issue creator (skips if already assigned) - pull_request_target: assigns the PR author (skips bots and PRs that already have assignees) Pairs with the existing issue-triage workflow, which will then remove the 'triage' label automatically once the assignee is set.
Contributor
|
Left comments on the issue ;) |
Address review feedback from #4551: - Remove the issue-author auto-assign. New issues stay unassigned so issue-triage.yml's 'triage' label takes effect — triage is a human decision and shouldn't be skipped. - Add credit-issue-on-pr-merge: on PR merge, find linked issues via the GraphQL closingIssuesReferences edge (covers Closes / Fixes / Resolves keywords and the manual sidebar linking) and replace their assignees with the PR author so credit goes to whoever actually shipped the fix, even if the issue had been assigned to someone else originally. The assign-pr-author job is unchanged.
Contributor
Author
Please check again. |
Contributor
|
It's hard to check. Can you try an issue/PR on your fork first to see if it works? And please share the links here |
Address review feedback from @Yicong-Huang on #4551: reopened/ready_for_review are no-ops because the PR already has the author as assignee from the original 'opened' event, so they only trigger a wasted job run. Drop them and keep just [opened, closed]: - opened - triggers assign-pr-author - closed - triggers credit-issue-on-pr-merge (gated on merged==true)
Address review feedback from @Yicong-Huang on #4551: A PR can have multiple authors via Co-authored-by trailers or distinct commit authors, and we should credit all of them on the linked issue, not only the PR opener. The credit-issue-on-pr-merge job now collects every distinct human author from the PR's commits via GraphQL (commit.authors.nodes — exposes Co-authored-by trailers as separate authors), seeded with the PR opener as a fallback. Merge commits (parents > 1) are skipped so a 'merge main into branch' doesn't credit the merger. Bot accounts and emails with no linked GitHub user are filtered out. The final assignee set on each linked issue is reconciled to exactly that author list — extra assignees removed, missing authors added — so the job is idempotent on re-run. Capped at GitHub's 10-assignee-per-issue limit.
The credit-issue-on-pr-merge job's script was truncated mid-statement, causing every PR merge to fail with SyntaxError: Unexpected token ')'. Add the missing per-issue body: skip cross-repo, diff current vs. credited assignees, removeAssignees for those no longer credited, and addAssignees for newly credited authors. Both calls are wrapped in try/catch so a permissions or 422 hiccup on one issue doesn't abort the rest. Verified end-to-end on aglinxinyuan/texera: issue #4 correctly received @aglinxinyuan as assignee after PR #5 merged with 'Closes #4'.
Move bot/already-assigned skips into job-level if-conditions, drop the verbose per-step logging and try/catch wrappers, and inline the GraphQL destructure. Behavior unchanged: PR opener (and commit Co-authors) are assigned at open time, then linked-issue assignees are replaced with those credited authors at merge time. 242 lines -> 96. Verified end-to-end on aglinxinyuan/texera: - aglinxinyuan#7 opened -> auto-assigned - aglinxinyuan#8 merged with 'Closes #6' -> issue assignee set
Contributor
Author
|
@Yicong-Huang tested end-to-end on my fork. Job 1 — assign-pr-author (PR open → author assigned): Job 2 — credit-issue-on-pr-merge (PR merge → linked issue assignees replaced with credited authors):
Ready for another look. |
Contributor
Thanks! let's follow the norm to put this test information in "How was this PR tested?" section of Pr templates. |
Yicong-Huang
approved these changes
Apr 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this PR?
Adds
.github/workflows/auto-assign.ymlwith two jobs:assign-pr-author — on
opened/reopened/ready_for_review, assigns the PR author as the assignee. Skips bots and PRs that already have an assignee.credit-issue-on-pr-merge — on PR merge (
pull_request_target: closed+merged == true), uses the GraphQLclosingIssuesReferencesedge to find the issues this PR closes, then replaces their assignees with the PR author. This coversCloses/Fixes/Resolveskeywords and the manual "Linked issues" sidebar relationship.New issues are intentionally left unassigned so the existing
issue-triage.ymlworkflow can keep them in thetriagequeue until a human assigns them.Any related issues, documentation, discussions?
Closes #4550
How was this PR tested?
Job 1 — assign-pr-author (PR open → author assigned):
aglinxinyuan#7 → run ✅
aglinxinyuan#8 → run ✅
Job 2 — credit-issue-on-pr-merge (PR merge → linked issue assignees replaced with credited authors):
aglinxinyuan#8 merged with Closes #6 → run ✅, aglinxinyuan#6 assignee correctly set.
Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.7)