fix(ci): make Sync-from-Docs auto-merge actually work#143
Merged
acedatacloud-dev merged 1 commit intomainfrom May 5, 2026
Merged
fix(ci): make Sync-from-Docs auto-merge actually work#143acedatacloud-dev merged 1 commit intomainfrom
acedatacloud-dev merged 1 commit intomainfrom
Conversation
Port the Skills-repo fix (AceDataCloud/Skills#181) to APIs. The current sync-from-docs.yml has 5 compounding bugs that cause every dispatch to leak one or more PRs: 1. Agent-done detection used 'gh api .../actions/runs?event=dynamic' filtered by run name. Returns 0 hits / null conclusion most of the time, so the polling default 'pending' sticks for the full 30-min window. 2. PR detector grabbed the first copilot/* branch it saw, not the one bound to the current issue. Stale PRs from prior runs get tracked instead of the new one. 3. create-task closed prior issues but not their orphaned PRs (including 0-commit zombies from agent boot failures). 4. timeout-minutes 35 + 90x20s polling = 30-min budget, shorter than typical Copilot sync runs. 5. gh pr merge had no --delete-branch, no retry, and shared the polling job. Result: 40+ open copilot/* PRs (mix of stale syncs and 0-commit zombies). This commit: - Pre-cleanup: closes every leftover open copilot/* PR at start of each dispatch (with branch deletion). - Reliable completion signal: poll isDraft == false (Copilot marks ready when its agent finishes). - PR-to-issue binding: locate PR via #<issue> in body, single-PR fallback. - Zombie guard: auto-close 0-commit PRs after 30 min. - Bigger budget: timeout 35->60 min, polling 90x20s -> 110x30s = 55 min. - Hardened merge: pr ready + check settle + 3-retry merge --admin --delete-branch. - Wider permissions: contents/pull-requests write so GITHUB_TOKEN fallback works.
This was referenced May 5, 2026
Closed
Closed
Closed
Closed
Closed
Closed
Closed
Closed
Closed
Closed
Closed
Closed
Closed
This was referenced May 5, 2026
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.
Why
The
Sync from Docsworkflow has been silently broken since it was created — everydocs-updateddispatch leaks one or more PRs (stale drafts or 0-commit zombies), causing the open-PR backlog you can see in the queue right now (APIs ~40, Clis ~30, SDK ~7).The Skills repo had the exact same workflow with the exact same bugs and was fixed in AceDataCloud/Skills#181. This PR ports that fix verbatim. The fix has been running cleanly in Skills for several days.
Root cause — five compounding bugs
gh api .../actions/runs?event=dynamicfiltered by workflow-run name. That query regularly returns 0 hits or a nullconclusion, so the polling default"pending"sticks for the entire window.copilot/*branch it saw, not the one bound to the current issue.create-taskclosed prior issues but not their orphaned PRs (including 0-commit zombies from agent boot failures).timeout-minutes: 35plus 90×20 s polling = 30-min budget, shorter than typical Copilot sync runs.gh pr mergehad no--delete-branch, no retry, and shared the polling job.What this PR does
create-tasknow closes every leftover opencopilot/*PR at the start of each dispatch (with branch deletion), not just the prior auto-sync issues. A new Docs commit makes prior attempts stale by definition.#<issue>in PR body (Copilot's standard linking format), with a single-PR fallback.workflow_runspoll with the observable signalisDraft == false. Copilot itself marks PRs ready-for-review when its agent finishes successfully.copilot/*PR open for 30 min with 0 commits is auto-closed (with branch deleted).timeout-minutes35 → 60, polling 90×20 s → 110×30 s = 55 min.gh pr ready(idempotent) → settle checks →gh pr merge --squash --admin --delete-branchwith up to 3 retries. On final failure, comments on the PR.contents: write,pull-requests: writeso the job can actually merge and delete branches underGITHUB_TOKEN(also helpful as fallback if a secret rotates).Outcome contract
After this lands, every
docs-updateddispatch resolves to one of three outcomes:No more silent draft accumulation.
Backlog cleanup
The existing open
copilot/*PRs in this repo will be closed in a follow-up bulk-cleanup pass after this PR lands (the newcreate-taskstep would close them on the next dispatch anyway, but doing it explicitly produces a cleaner audit trail).Test plan
yaml.safe_load).docs-updateddispatch from PlatformBackend.