Fix auto-pr to not fail when branches are already in sync

This commit is contained in:
2026-03-02 15:08:24 +03:00
parent 2177683838
commit 6939dfd4c3
+9 -3
View File
@@ -18,17 +18,23 @@ jobs:
env: env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: | run: |
# Check if there's already an open PR from master to main
EXISTING_PR=$(gh pr list --base main --head master --state open --json number --jq '.[0].number') EXISTING_PR=$(gh pr list --base main --head master --state open --json number --jq '.[0].number')
if [ -n "$EXISTING_PR" ]; then if [ -n "$EXISTING_PR" ]; then
echo "PR #$EXISTING_PR already exists — new commits will appear automatically" echo "PR #$EXISTING_PR already exists — new commits will appear automatically"
else exit 0
fi
echo "Creating new PR: master → main" echo "Creating new PR: master → main"
gh pr create \ if gh pr create \
--base main \ --base main \
--head master \ --head master \
--title "Sync: master → main" \ --title "Sync: master → main" \
--body "Automated PR to sync master branch changes to main. --body "Automated PR to sync master branch changes to main.
This PR was created automatically and will be merged once CI checks pass." This PR was created automatically and will be merged once CI checks pass."; then
echo "PR created successfully"
else
echo "PR creation skipped (branches may already be in sync)"
fi fi