ci: opt-in auto-update of PRs labeled 'updateme'#231
Merged
Conversation
Adds a workflow that runs on every push to main. For each open PR labeled 'updateme' it calls `gh pr update-branch` to merge the new tip of main into the PR branch. PRs without the label are left alone. PRs from forks are skipped because GITHUB_TOKEN cannot push to a fork's branch via the update-branch endpoint; conflicting PRs are logged and skipped. The concurrency group serializes runs so two close-together merges don't race the API. Documents the opt-in label in README under a new Contributing section. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an opt-in GitHub Actions automation to keep selected pull requests up to date by updating their branches whenever main advances, with brief contributor-facing documentation.
Changes:
- Introduces a new workflow that, on every push to
main, finds open PRs labeledupdatemeand runsgh pr update-branchfor each (skipping fork PRs). - Adds a README Contributing section documenting the
updatemelabel behavior and limitations.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
.github/workflows/auto-update-prs.yml |
New workflow to update labeled PR branches on main pushes. |
README.md |
Documents how to opt in via the updateme label and notes limitations. |
Comments suppressed due to low confidence (2)
.github/workflows/auto-update-prs.yml:27
- The workflow/README describe merging
maininto labeled PRs, butgh pr update-branchupdates from each PR’s base branch. If you want strictlymain, filter the PR list tobaseRefName == "main"(addbaseRefNameto--jsonand select in--jq), or update the documentation to reflect that it updates whatever base branch the PR targets.
gh pr list --repo "$GITHUB_REPOSITORY" --state open --label updateme \
--json number,isCrossRepository \
--jq '.[] | "\(.number) \(.isCrossRepository)"' \
README.md:102
- The workflow doesn’t remove the
updatemelabel on conflicts, so auto-updates will keep retrying on every subsequent push tomain. The doc line about needing to “re-apply the label” after resolving conflicts is misleading; consider removing that part or describing the actual resume behavior.
- Only works for PRs from branches in this repository. PRs from forks cannot be pushed to via the workflow's token and will be skipped (the workflow logs which PRs it skipped).
- If the update would cause a merge conflict, the PR is left as-is. Resolve the conflict by hand and re-apply the label if you want auto-update to resume.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Use set -euo pipefail so a failed `gh pr list` (auth/rate limit/API outage) fails the job loudly instead of being masked by the empty while loop exiting 0. - Filter to PRs whose baseRefName == "main" so we only touch PRs that actually target the branch we just pushed to. `gh pr update-branch` merges from the PR's base branch, so this matches the workflow's documented intent. - README: align language with the new base-branch filter; remove the misleading "re-apply the label" line — the workflow never removes the label, so the next push to main retries automatically. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- `gh pr list --limit 200` so we don't silently truncate at the default 30. Realistically this never matters for this repo, but silent truncation is the wrong default. - Generalize the per-PR failure log: `gh pr update-branch` can return non-zero for many reasons (merge conflict, branch protection, transient API error, deleted head ref), not just conflicts. Refer readers to the preceding `gh` output rather than claiming "likely conflicting". - README: same class-fix — the limitations section now lists representative failure causes instead of saying "merge conflict" exclusively. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 14, 2026
Merged
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.
Summary
.github/workflows/auto-update-prs.yml: on every push tomain, iterate open PRs labeledupdatemeand callgh pr update-branchto merge newmaininto each PR branch.GITHUB_TOKENcannot push to a fork) with a clear log line; conflicting PRs are logged and skipped.concurrency:group serializes runs so back-to-back merges tomaindon't race the API.Setup after merge
Create the
updatemelabel once:Then add it to any PR you want kept current:
gh pr edit <num> --add-label updateme(or via the web UI).Test plan
ruff check— cleanpytest— passes (13 tests, unchanged)updatemelabel to a non-fork PR (e.g. dependabot's build(deps): bump softprops/action-gh-release from 2 to 3 #226), then push a trivial commit tomainand confirm the workflow updates build(deps): bump softprops/action-gh-release from 2 to 3 #226's branch.🤖 Generated with Claude Code