Repository navigation
[auto-backport] Assign backport PRs to the original PR author or merger - #21379
Merged
Merged
Conversation
When the auto-backport workflow opens a PR targeting a backport branch, resolve the assignee from the source PR that was merged into main: - Use the PR author if they are not a bot and have repo write access. - Fall back to whoever merged the PR if the author doesn't qualify. - Omit --assignee entirely if neither qualifies, so PR creation is not blocked. Resolution logic lives in Go (apply.go: resolveAssignee/pickAssignee), mirroring the approach introduced in sync.go for changelog-sync PRs. The workflow passes the original PR number via --origin-pr-number through backport_apply.sh to the backport binary, which performs the two API calls (gh pr view + collaborator permission check) internally. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move the duplicated prActor/resolveAssignee/pickAssignee logic from changelog/sync.go and apply/apply.go into a new cmd/backport/assign package with exported PRActor, Resolve, and Pick symbols. Both callers now import assign.Resolve and assign.Pick. The canonical unit tests live in assign/assign_test.go; the redundant TestPickAssignee copies in sync_test.go and apply_test.go are removed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Guard assign.Resolve behind opts.OpenPR to avoid redundant GitHub API calls when --open-pr is not set. - Document the PR_NUMBER optional env var in the process-checked-branches.sh header comment. - Add a comment to assign.Pick explaining why the mergedBy fallback skips the write-access check (GitHub requires write permission to merge). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Check hasWriteAccess for mergedBy in assign.Pick: a login that lost repo access after merging would cause gh pr create --assignee to fail and abort backport PR creation. Both author and mergedBy paths now verify write access before returning the login. - Skip assign.Resolve during DryRun (guard is now OpenPR && !DryRun): the resolved assignee is never consumed in a dry run, so the two GitHub API calls were wasted. - Update TestPick: use a login-selective predicate for the external- contributor case, and add a case covering a revoked-access merger. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
💚 Build Succeeded
cc @mrodm |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved blocking issues were identified.
Pull request overview
Updates automated backport and changelog-sync PR creation to assign eligible authors or mergers.
Changes:
- Adds shared assignee resolution logic and tests.
- Propagates the originating PR number through CLI and workflows.
- Applies resolved assignees to created PRs.
File summaries
| File | Description |
|---|---|
dev/scripts/backport_apply.sh |
Forwards the origin PR number. |
cmd/backport/main.go |
Adds the CLI option. |
cmd/backport/backports/changelog/sync.go |
Uses shared assignment logic. |
cmd/backport/backports/changelog/sync_test.go |
Removes migrated tests. |
cmd/backport/backports/apply/apply.go |
Assigns backport PRs automatically. |
cmd/backport/assign/assign.go |
Implements assignee resolution. |
cmd/backport/assign/assign_test.go |
Tests assignment scenarios. |
.github/workflows/auto-backport.yml |
Passes the source PR number. |
.github/scripts/backport/process-checked-branches.sh |
Forwards the source PR number. |
Review details
- Files reviewed: 9/9 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
mrodm
added a commit
to mrodm/integrations
that referenced
this pull request
Sep 17, 2026
…tion Add a paragraph to step 4 explaining that the sync-backport-changelog workflow now automatically assigns the sync PR to the backport PR's author (if not a bot and has write/maintain/admin access) or to the merger (if not a bot). Reflects elastic#21243, merged 2026-09-15. Add a sentence to the checklist comment section documenting that auto-backport PRs are automatically assigned to the original PR's author or merger using the same logic. Preemptive for elastic#21379 (open). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
5 tasks
mrodm
added a commit
to mrodm/integrations
that referenced
this pull request
Sep 18, 2026
…elastic#21379) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
teresaromero
approved these changes
Sep 18, 2026
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
Merged
3 tasks done
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.
Proposed commit message
[auto-backport] Assign backport PRs to the original PR author or merger
When the auto-backport workflow opens a PR targeting a backport branch,
resolve the assignee from the source PR that was merged into main using
the same logic introduced for sync-changelog PRs in #21243:
checked for write access to guard against revoked access post-merge).
blocked.
Resolution logic is centralised in a new cmd/backport/assign package
(PRActor, Resolve, Pick) shared by both the apply and changelog/sync
code paths, eliminating the duplication that existed between them.
The workflow passes the original PR number via --origin-pr-number through
backport_apply.sh to the backport binary, which performs the two API
calls (gh pr view + collaborator permission check) internally.
assign.Resolve is guarded by OpenPR && !DryRun to avoid redundant API
calls in non-PR paths.
Author's Checklist
assign.Pickis covered by unit tests (TestPick) including bot-author, external-contributor, revoked-access merger, and both-bots scenarios.assign.Resolveis only called whenOpenPR && !DryRunto avoid redundant GitHub API calls.sync.goandapply.gonow delegate toassign.Resolve/assign.Pick— no local duplicate definitions remain.Related issues
🤖 Generated with Claude Code