From 4628c187bd2af79b6507f6d9de7b6d12ec448e6c Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Thu, 10 Apr 2025 10:26:00 -0700 Subject: [PATCH] Update sync-main.yml --- .github/workflows/sync-main.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) 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 }}