Skip to content

ci: opt-in auto-update of PRs labeled 'updateme'#231

Merged
Olen merged 3 commits into
mainfrom
chore/ci-auto-update-prs
May 14, 2026
Merged

ci: opt-in auto-update of PRs labeled 'updateme'#231
Olen merged 3 commits into
mainfrom
chore/ci-auto-update-prs

Conversation

@Olen
Copy link
Copy Markdown
Owner

@Olen Olen commented May 14, 2026

Summary

  • Add .github/workflows/auto-update-prs.yml: on every push to main, iterate open PRs labeled updateme and call gh pr update-branch to merge new main into each PR branch.
  • Opt-in via label so it doesn't churn CI for every open PR — only those the maintainer flags participate.
  • Fork PRs are skipped (GITHUB_TOKEN cannot push to a fork) with a clear log line; conflicting PRs are logged and skipped.
  • concurrency: group serializes runs so back-to-back merges to main don't race the API.
  • README gets a short Contributing section documenting the label and its limitations.

Setup after merge

Create the updateme label once:

gh label create updateme --description "Auto-update from main on every merge" --color "0e8a16"

Then add it to any PR you want kept current: gh pr edit <num> --add-label updateme (or via the web UI).

Test plan

🤖 Generated with Claude Code

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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 labeled updateme and runs gh pr update-branch for each (skipping fork PRs).
  • Adds a README Contributing section documenting the updateme label 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 main into labeled PRs, but gh pr update-branch updates from each PR’s base branch. If you want strictly main, filter the PR list to baseRefName == "main" (add baseRefName to --json and 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 updateme label on conflicts, so auto-updates will keep retrying on every subsequent push to main. 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.

Comment thread .github/workflows/auto-update-prs.yml Outdated
Comment thread README.md Outdated
- 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>
@Olen Olen requested a review from Copilot May 14, 2026 08:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread .github/workflows/auto-update-prs.yml Outdated
Comment thread .github/workflows/auto-update-prs.yml Outdated
- `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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@Olen Olen merged commit 9f503c4 into main May 14, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants