Skip to content

Commit f94cc53

Browse files
committed
only make a new PR if one isnt already there
1 parent c70d13d commit f94cc53

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

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

Lines changed: 12 additions & 3 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

0 commit comments

Comments
 (0)