diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 87ad2d834460..fa4d2cdeecd3 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -72,13 +72,17 @@ jobs: if [ -n "$pr_number" ]; then echo "PR from auto/sync-main-pr to main already exists (PR #$pr_number). Exiting gracefully." else - echo "PR does not exist. Creating one..." - gh pr create --repo microsoft/codeql --fill -B main -H auto/sync-main-pr \ - --label 'autogenerated' \ - --title 'Sync Main (autogenerated)' \ - --body "This PR syncs the latest changes from \`codeql-cli/latest\` into \`main\`." \ - --reviewer 'MathiasVP' - --reviewer 'ropwareJB' + if git fetch origin main auto/sync-main-pr && [ -n "$(git rev-list origin/main..origin/auto/sync-main-pr)" ]; then + echo "PR does not exist. Creating one..." + gh pr create --repo microsoft/codeql --fill -B main -H auto/sync-main-pr \ + --label 'autogenerated' \ + --title 'Sync Main (autogenerated)' \ + --body "This PR syncs the latest changes from \`codeql-cli/latest\` into \`main\`." \ + --reviewer 'MathiasVP' + --reviewer 'ropwareJB' + else + echo "No changes to sync from auto/sync-main-pr to main. Exiting gracefully." + fi fi env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}