File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff 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
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 }}
You can’t perform that action at this time.
0 commit comments