Skip to content

Commit 018f155

Browse files
KyleAMathewsclaude
andauthored
fix(ci): reuse existing open docs PR instead of creating duplicates (#1461)
* fix(ci): reuse existing open docs PR instead of creating duplicates 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> * fix(ci): address review findings in docs PR reuse logic - 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> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1e69dd6 commit 018f155

1 file changed

Lines changed: 25 additions & 8 deletions

File tree

.github/workflows/release.yml

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,34 @@ jobs:
5050
git config user.name "github-actions[bot]"
5151
git config user.email "github-actions[bot]@users.noreply.github.com"
5252
53-
BRANCH="docs/auto-update-$(date +%s)"
54-
git checkout -b "$BRANCH"
53+
EXISTING_BRANCH=$(gh pr list --author "app/github-actions" --search "docs: regenerate API documentation in:title" --state open --json headRefName --jq '.[0].headRefName' 2>/dev/null || echo "")
54+
CREATE_PR=true
55+
56+
if [ -n "$EXISTING_BRANCH" ] && [ "$EXISTING_BRANCH" != "null" ]; then
57+
BRANCH="$EXISTING_BRANCH"
58+
echo "Found existing docs PR on branch $BRANCH, updating it"
59+
git checkout -B "$BRANCH"
60+
CREATE_PR=false
61+
else
62+
BRANCH="docs/auto-update-$(date +%s)"
63+
git checkout -b "$BRANCH"
64+
fi
65+
5566
git add docs/
67+
if git diff --cached --quiet; then
68+
echo "No new docs changes to commit"
69+
exit 0
70+
fi
5671
git commit -m "docs: regenerate API documentation"
57-
git push origin "$BRANCH"
72+
git push --force-with-lease origin "$BRANCH"
5873
59-
gh pr create \
60-
--title "docs: regenerate API documentation" \
61-
--body "Automated documentation update from release" \
62-
--base main \
63-
--head "$BRANCH"
74+
if [ "$CREATE_PR" = true ]; then
75+
gh pr create \
76+
--title "docs: regenerate API documentation" \
77+
--body "Automated documentation update from release" \
78+
--base main \
79+
--head "$BRANCH"
80+
fi
6481
else
6582
echo "No changes in generated docs"
6683
fi

0 commit comments

Comments
 (0)