fix(ci): check out the sync branch before transforming, and serialize runs - #343
Merged
Conversation
… runs Mirrors cosmos/example#16 and #17 in the reverse direction. The workflow transformed the tutorials into cosmos-example/ while still on main, then stashed, switched to the open sync branch, and popped. Popping a stash taken against main onto a branch that already carries overlapping changes conflicts and exits 1, which fails the step under bash -e. That is the likely cause of the unexplained 2026-04-10 failure, which ran while cosmos/example#9 had been open since March 31. Select the target branch and check it out first, while the tree is still clean, then transform directly onto it. Nothing is stashed and nothing is merged, so there is no conflict to hit. Replaces the separate change-detection step with a `git diff --cached --quiet` guard so an up-to-date branch exits cleanly instead of creating an empty commit. Also adds a concurrency group, so two overlapping runs cannot derive divergent commits from the same branch revision and race on push, and workflow_dispatch, so a sync PR left stale by a failed run can be brought current without waiting for the next docs edit. Verified against real clones of cosmos/docs and cosmos/example using the stale cosmos/example#9 branch: with the transform output overlapping lines that branch already changed, the old sequence produces "CONFLICT (content): Merge conflict in docs/02-quickstart.md" and exits 1, while the new sequence exits 0 and stages the correct refresh.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
Contributor
Greptile SummaryThis PR repairs the reverse documentation-sync workflow by selecting an existing sync branch before transformation and eliminating the conflict-prone stash application.
Confidence Score: 5/5The PR appears safe to merge, with no actionable blocking or non-blocking defects identified in the changed workflow. The workflow now transforms directly on the intended branch, avoids stash conflicts, skips empty commits, and serializes updates while preserving the newest generated state. Important Files Changed
|
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.
Mirrors cosmos/example#16 and #17 in the reverse direction. The forward workflow had the same structural bug; it has been fixed and verified in CI, and this brings the two back into parity.
Problem
docs-sync-to-example.ymltransforms the tutorials intocosmos-example/while still onmain, then switches to the open sync branch to commit:Popping a stash taken against
mainonto a branch that already carries overlapping changes conflicts:run:blocks execute underbash -e, so exit 1 fails the step. This is conditional, not constant: it fires when the transform output touches lines the sync branch already changed, which is exactly what happens when that branch carries an earlier version of the same edit. This is the likely cause of the unexplained 2026-04-10 failure, which ran whilecosmos/example#9had been open since March 31. That run's logs have expired, so the attribution is inference, not proof.Without the stash,
git checkoutaborts outright with "local changes would be overwritten," which is how the forward workflow was failing.Fix
Select the target branch and check it out first, while the tree is still clean, then transform directly onto it. Nothing is stashed and nothing is merged, so there is no conflict to hit.
Three supporting changes:
git diff --cached --quietguard, so an already-current branch exits cleanly rather than creating an empty commit.concurrencygroup, so two overlapping runs cannot derive divergent commits from the same branch revision and race on push, where the loser is rejected non-fast-forward and its update silently lost.workflow_dispatch, so a sync PR left stale by a failed run can be brought current without waiting for the next docs edit. The loop guard is unaffected: with nohead_commiton a dispatch,contains()is false and the job runs.Verification
Against real clones of both repos, using the stale
cosmos/example#9branch as the existing-PR case, with the transform output edited to overlap lines that branch already changed:CONFLICT (content): Merge conflict in docs/02-quickstart.md, exit 1The equivalent fix in
cosmos/examplehas since run green in CI twice, once updating an open sync PR and once correctly reporting nothing to do.Note on cosmos/example#9
That sync PR has been open since 2026-03-31 and its branch is five months stale. Once this merges, the next reverse sync will reuse and wholesale refresh it, turning it into a large diff (~225 insertions, ~50 deletions) rather than the small one a reviewer might expect. Closing it first is probably cleaner, so the next run opens a fresh PR.