Skip to content

Commit e7dd21b

Browse files
authored
[Docs Site] Fix branch name in API schema workflow (#21417)
1 parent c6efcf8 commit e7dd21b

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

.github/workflows/update-api-schemas.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,23 @@ jobs:
3333
- name: Create PR if needed
3434
if: steps.get-commit.outputs.latest_commit != steps.check-current.outputs.current_commit
3535
run: |
36-
# Create a new branch
36+
# Set up git config
3737
git config --global user.name 'github-actions[bot]'
3838
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
39-
BRANCH_NAME="update-api-schemas-$(date +%Y%m%d-%H%M%S)"
39+
NEW_COMMIT="${{ steps.get-commit.outputs.latest_commit }}"
40+
BRANCH_NAME="update-api-schemas-$NEW_COMMIT"
41+
42+
# Check if PR already exists
43+
EXISTING_PR=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number')
44+
if [ -n "$EXISTING_PR" ]; then
45+
echo "PR already exists for branch $BRANCH_NAME. Skipping PR creation."
46+
exit 0
47+
fi
48+
49+
# Create a new branch
4050
git checkout -b $BRANCH_NAME
4151
4252
# Update the commit reference
43-
NEW_COMMIT="${{ steps.get-commit.outputs.latest_commit }}"
4453
sed -i "s/const COMMIT = \".*\"/const COMMIT = \"$NEW_COMMIT\"/" src/util/api.ts
4554
4655
# Commit and push changes
@@ -52,7 +61,7 @@ jobs:
5261
gh pr create \
5362
--title "[Docs Site] Update pinned api-schemas commit" \
5463
--body "This PR updates the api-schemas commit reference to the latest version ($NEW_COMMIT)." \
55-
--base main \
64+
--base production \
5665
--head $BRANCH_NAME
5766
env:
5867
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)