Skip to content

ci: auto-assign PR author, credit author on issue close#4551

Merged
Yicong-Huang merged 7 commits into
mainfrom
chore/auto-assign-author
Apr 29, 2026
Merged

ci: auto-assign PR author, credit author on issue close#4551
Yicong-Huang merged 7 commits into
mainfrom
chore/auto-assign-author

Conversation

@aglinxinyuan
Copy link
Copy Markdown
Contributor

@aglinxinyuan aglinxinyuan commented Apr 28, 2026

What changes were proposed in this PR?

Adds .github/workflows/auto-assign.yml with two jobs:

  1. 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.

  2. credit-issue-on-pr-merge — on PR merge (pull_request_target: closed + merged == true), uses the GraphQL closingIssuesReferences edge to find the issues this PR closes, then replaces their assignees with the PR author. This covers Closes / Fixes / Resolves keywords and the manual "Linked issues" sidebar relationship.

New issues are intentionally left unassigned so the existing issue-triage.yml workflow can keep them in the triage queue 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#7run
aglinxinyuan#8run
Job 2 — credit-issue-on-pr-merge (PR merge → linked issue assignees replaced with credited authors):

aglinxinyuan#8 merged with Closes #6run ✅, aglinxinyuan#6 assignee correctly set.

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Opus 4.7)

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.
@aglinxinyuan aglinxinyuan self-assigned this Apr 28, 2026
@github-actions github-actions Bot added the ci changes related to CI label Apr 28, 2026
@Yicong-Huang
Copy link
Copy Markdown
Contributor

Left comments on the issue ;)

aglinxinyuan and others added 2 commits April 28, 2026 18:21
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.
@aglinxinyuan aglinxinyuan changed the title ci: auto-assign issue/PR author as assignee ci: auto-assign PR author as assignee Apr 29, 2026
@aglinxinyuan aglinxinyuan changed the title ci: auto-assign PR author as assignee ci: auto-assign PR author, credit author on issue close Apr 29, 2026
@aglinxinyuan
Copy link
Copy Markdown
Contributor Author

Left comments on the issue ;)

Please check again.

@Yicong-Huang
Copy link
Copy Markdown
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

Comment thread .github/workflows/auto-assign.yml Outdated
Comment thread .github/workflows/auto-assign.yml Outdated
Comment thread .github/workflows/auto-assign.yml Outdated
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
@aglinxinyuan
Copy link
Copy Markdown
Contributor Author

aglinxinyuan commented Apr 29, 2026

@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.

@Yicong-Huang
Copy link
Copy Markdown
Contributor

@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.

Thanks! let's follow the norm to put this test information in "How was this PR tested?" section of Pr templates.

@Yicong-Huang Yicong-Huang enabled auto-merge (squash) April 29, 2026 05:28
@Yicong-Huang Yicong-Huang merged commit 3471e60 into main Apr 29, 2026
13 checks passed
@Yicong-Huang Yicong-Huang deleted the chore/auto-assign-author branch April 29, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci changes related to CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-assign PR author, and credit PR author on issue close

2 participants