fix(ci): reuse existing open docs PR instead of creating duplicates#1461
Merged
KyleAMathews merged 2 commits intomainfrom Apr 7, 2026
Merged
fix(ci): reuse existing open docs PR instead of creating duplicates#1461KyleAMathews merged 2 commits intomainfrom
KyleAMathews merged 2 commits intomainfrom
Conversation
The release workflow now checks for an existing open "regenerate API documentation" PR before creating a new one. If found, it pushes new docs changes to that PR's branch instead of spawning a duplicate. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
More templates
@tanstack/angular-db
@tanstack/browser-db-sqlite-persistence
@tanstack/capacitor-db-sqlite-persistence
@tanstack/cloudflare-durable-objects-db-sqlite-persistence
@tanstack/db
@tanstack/db-ivm
@tanstack/db-sqlite-persistence-core
@tanstack/electric-db-collection
@tanstack/electron-db-sqlite-persistence
@tanstack/expo-db-sqlite-persistence
@tanstack/node-db-sqlite-persistence
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/react-native-db-sqlite-persistence
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/tauri-db-sqlite-persistence
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
Contributor
|
Size Change: 0 B Total Size: 114 kB ℹ️ View Unchanged
|
Contributor
|
Size Change: 0 B Total Size: 4.24 kB ℹ️ View Unchanged
|
- Use git checkout -B to reset branch to current HEAD (avoids dirty working tree conflict and keeps freshly generated docs) - Use --force-with-lease for push since branch history is rewritten - Guard git commit with diff --cached --quiet for no-change case - Handle gh pr list failure gracefully with fallback to new PR - Narrow PR search with --author and in:title filters - Use separate CREATE_PR variable instead of dual-purpose state Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
samwillis
approved these changes
Apr 7, 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.
Summary
The release workflow's "Commit Generated Docs" step now reuses an existing open docs PR instead of creating a duplicate each time packages are published.
Root Cause
Every release that generated docs changes created a new timestamped branch (
docs/auto-update-{epoch}) and a new PR. If multiple releases happened before a docs PR was merged, stale duplicates accumulated.Approach
Before creating a new branch, the workflow searches for an existing open PR authored by
github-actions[bot]with the docs regeneration title. If found, it resets that branch to the currentmain(where fresh docs were just generated) and force-pushes. If not found, it creates a new branch and PR as before.Key implementation details:
git checkout -B "$BRANCH"resets the existing branch to current HEAD, keeping the freshly generated docs in the working tree. A plaingit checkoutwould fail (dirty working tree conflict) and discard the new docs.--force-with-leaseis needed since the branch history is rewritten to always sit on latestmain.git diff --cached --quietguard exits cleanly when docs are unchanged, avoiding agit commitfailure underset -e.--author+in:titlefilters narrow the PR search to avoid matching unrelated PRs.2>/dev/null || echo ""ongh pr listensures API failures fall back to creating a new PR.Key Invariants
mainwhere docs were generatedgh pr listfailure never blocks the docs update — it falls back to creating a new PRNon-goals
maininto the existing branch — resetting tomainis simpler and produces a cleaner diffVerification
# Syntax check actionlint .github/workflows/release.ymlManual verification on next release:
Files changed
.github/workflows/release.yml— Rewrote the "Commit Generated Docs" step to search for and reuse existing open docs PRs🤖 Generated with Claude Code