Skip to content

Commit 85aeea3

Browse files
committed
chore: check for push outside of the box
1 parent 84d60c0 commit 85aeea3

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

.github/workflows/stable-sync.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,15 @@ jobs:
5454
CREATE_BRANCH: 'false'
5555
run: |
5656
node .github/scripts/stable-sync.js "stable-main-${{ inputs.semver-version }}"
57-
# Push the branch to origin using GitHub CLI
58-
git push --set-upstream origin "stable-main-${{ inputs.semver-version }}"
57+
# Check if branch exists remotely
58+
BRANCH_NAME="stable-main-${{ inputs.semver-version }}"
59+
if git ls-remote --heads origin "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then
60+
echo "Branch $BRANCH_NAME exists remotely, pushing normally"
61+
git push origin "$BRANCH_NAME"
62+
else
63+
echo "Branch $BRANCH_NAME doesn't exist remotely, pushing with --set-upstream"
64+
git push --set-upstream origin "$BRANCH_NAME"
65+
fi
5966
6067
- name: Create Pull Request
6168
if: steps.check-pr.outputs.result != 'true'

0 commit comments

Comments
 (0)