ci: reclaim orphan sync branches inline in sync workflows#291
Merged
Conversation
When a sync PR is closed without merging, its head branch lingers on remote (the repo "Automatically delete head branches" setting only fires on merge, not close). If the next sync workflow run targets the same upstream SHA — rare but possible when upstream hasn't advanced between attempts — the branch name collides and `git push` fails with non-fast-forward. Add a defensive reclaim block to each sync workflow's create-branch step: before pushing, if the target branch already exists on remote AND no open PR uses it as head, delete it. PHASE A's blocking check already guarantees no open sync*/* PR with the matching prefix; this catches branches orphaned by close-without-merge. Net effect: closing a sync PR + re-running the workflow now works unconditionally, even when the upstream SHA hasn't changed between attempts. No separate cleanup workflow needed.
afrind
approved these changes
May 6, 2026
Contributor
afrind
left a comment
There was a problem hiding this comment.
@afrind reviewed 1 file and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on akash-a-n, michalhosna, mondain, Oxyd, peterchave, suhasHere, and TimEvens).
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
Add a defensive orphan-reclaim block to each sync workflow's create-branch step. When a sync PR is closed without merging, its head branch lingers on remote — the repo "Automatically delete head branches" setting only fires on merge, not close. If the next sync workflow run targets the same upstream SHA (rare but possible when upstream hasn't advanced between attempts), the branch name collides and
git pushfails with non-fast-forward, blocking the cron cascade.Behavior
Before each sync workflow's
git push:Net effect: closing a sync PR + re-running the workflow now works unconditionally, even when the upstream SHA hasn't changed between attempts. No manual branch cleanup, no separate cleanup workflow with skipped run noise.
Why inline instead of a separate cleanup workflow
Earlier today we tried a
pull_request: closedworkflow (since-closed PR #10 in picoquic, closed PRs #205 in moxygen / #289 in moqx). It worked but produced "skipped" run records on every PR close in the repo (GitHub doesn't support head-branch filtering onpull_requesttriggers). Visual noise on the Actions UI made non-green entries unreliable as a problem signal.Weaving the cleanup into the sync workflow itself fixes the same problem with no Actions UI noise — the cleanup only happens when actually needed, as part of the normal sync run.
Test plan
gh workflow run) — confirm the orphan-reclaim warning fires and the new sync PR opens cleanly.Related
.github/workflows/sync-branch-cleanup-on-close.yml— the close-trigger workflow merged via PR Draft: Configuration and hot-reloading. #10. Picoquic-only; the same change in moxygen / moqx never merged. (Picoquic PR only.)This change is