Skip to content

Commit e6b0b06

Browse files
KyleAMathewsclaude
andcommitted
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 <[email protected]>
1 parent e064c72 commit e6b0b06

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

.github/workflows/release.yml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,29 @@ 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"
55-
git add docs/
56-
git commit -m "docs: regenerate API documentation"
57-
git push origin "$BRANCH"
53+
EXISTING_PR=$(gh pr list --search "docs: regenerate API documentation" --state open --json number,headRefName --jq '.[0]')
5854
59-
gh pr create \
60-
--title "docs: regenerate API documentation" \
61-
--body "Automated documentation update from release" \
62-
--base main \
63-
--head "$BRANCH"
55+
if [ -n "$EXISTING_PR" ] && [ "$EXISTING_PR" != "null" ]; then
56+
BRANCH=$(echo "$EXISTING_PR" | jq -r '.headRefName')
57+
echo "Found existing docs PR on branch $BRANCH, updating it"
58+
git checkout "$BRANCH"
59+
git pull origin "$BRANCH"
60+
git add docs/
61+
git commit -m "docs: regenerate API documentation"
62+
git push origin "$BRANCH"
63+
else
64+
BRANCH="docs/auto-update-$(date +%s)"
65+
git checkout -b "$BRANCH"
66+
git add docs/
67+
git commit -m "docs: regenerate API documentation"
68+
git push origin "$BRANCH"
69+
70+
gh pr create \
71+
--title "docs: regenerate API documentation" \
72+
--body "Automated documentation update from release" \
73+
--base main \
74+
--head "$BRANCH"
75+
fi
6476
else
6577
echo "No changes in generated docs"
6678
fi

0 commit comments

Comments
 (0)