fix(ci): prevent duplicate PRs in publish-docs workflow - #149
Conversation
Use a static branch name instead of run_id-suffixed branches so re-runs update the existing PR via force-push rather than opening new ones. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Use --allow-empty so every run force-pushes to the static branch and the "Create PR" step always runs, keeping the PR's last-updated time current regardless of whether docs content changed. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
fercor-cisco
left a comment
There was a problem hiding this comment.
🤖 This review was generated by the Astra agent (claude-opus-4-8). It may contain mistakes.
Verdict: request_changes — The duplicate-PR check filters on --base main but gh pr create omits -B main, so if the docs repo's default branch isn't main the dedup silently breaks; and dropping the no-changes guard now opens/churns a PR on every run even with zero doc changes.
Follow-ups
Suggested follow-up work that could be tracked as Shortcut stories:
.github/workflows/publish-docs.yaml:53-53: Thegit fetch origin ... 2>/dev/nullsuppresses stderr, which hides genuine fetch failures (auth/network) and makes the fallback togit checkout -bindistinguishable from the expected 'branch does not exist yet' case. Consider checking for the ref explicitly (e.g.git ls-remote --exit-code --heads origin <branch>) so real errors aren't masked.
- Add -B main -H $BRANCH_NAME to gh pr create so base branch is explicit and consistent with the --head filter in pr list - Drop --base main from gh pr list to avoid silent dedup failure if docs repo default branch ever changes - Vary commit message (no-change vs actual update) to reduce noise in docs repo history Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
fercor-cisco
left a comment
There was a problem hiding this comment.
🤖 This review was generated by the Astra agent (claude-opus-4-8). It may contain mistakes.
Verdict: request_changes — Branch-reuse step likely fails to check out the existing docs branch and force-push then discards reviewer commits; empty-commit noise concern remains unaddressed.
Follow-ups
Suggested follow-up work that could be tracked as Shortcut stories:
.github/workflows/publish-docs.yaml:98-99: Shell variables like$BRANCH_NAMEare used unquoted ingh pr list --head $BRANCH_NAMEandgh pr create ... -H $BRANCH_NAME. It works today because branch names contain no whitespace, but quoting ("$BRANCH_NAME") would silence shellcheck SC2086 and is more defensive. Non-blocking style cleanup.
- Branch reuse: use `git checkout -B ... FETCH_HEAD` so the existing remote branch is reliably checked out after a shallow fetch (fixes silent fallback to a fresh branch that could wipe reviewer commits) - No-op guard: restore has_changes check; only commit/push/create PR when docs actually changed — empty-commit noise eliminated - Quote $BRANCH_NAME in gh pr list/create to satisfy shellcheck SC2086 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
fercor-cisco
left a comment
There was a problem hiding this comment.
🤖 This review was generated by the Astra agent (claude-opus-4-8). It may contain mistakes.
Verdict: approve — Small, well-scoped CI fix; all four prior review findings are resolved in the current HEAD and the logic matches the proven regenerate-api-client pattern.
Follow-ups
Suggested follow-up work that could be tracked as Shortcut stories:
.github/workflows/publish-docs.yaml:53-53: Thegit fetch ... && git checkout -B ... FETCH_HEAD || git checkout -b ...uses theA && B || Cidiom: ifgit checkout -B ... FETCH_HEADwere to fail after a successful fetch, the||fallback would silently create a fresh branch off the docs repo's default branch, and the latergit push --forcecould clobber the existing remote branch (including reviewer commits). Low probability, but an explicitif git fetch ...; then git checkout -B ... FETCH_HEAD; else git checkout -b ...; fiwould remove the ambiguity.
Summary
feat/update-docs-${GITHUB_REF_NAME}) instead of arun_id-suffixed one, so re-runs update the same branchgh pr create, and skip creation if one already existsThis applies the same pattern fixed in PR #139 (
regenerate-api-client.yaml) to the publish-docs workflow.Test plan
🤖 Generated with Claude Code