From 7e90d99c28fcffb0dc1abb4361e154ef0a065832 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 11:14:08 -0700 Subject: [PATCH 01/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index f10d5ce5bc51..fdbb7dccf28f 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - dilan/sync-main-bugs-6 paths: - .github/workflows/sync-main.yml schedule: @@ -53,8 +54,19 @@ jobs: echo "Branch not yet visible to GitHub — waiting a bit more" sleep 10 } + git branch + gh api repos/:owner/:repo/branches/sync-main-pr || { + echo "Branch not yet visible to GitHub — waiting a bit more" + sleep 10 + } - name: Create or update PR run: | + git branch + gh api repos/:owner/:repo/branches/sync-main-pr || { + echo "Branch not yet visible to GitHub — waiting a bit more" + sleep 10 + } + git branch gh api repos/:owner/:repo/branches/sync-main-pr PR_URL=$(gh pr list --head sync-main-pr --json url --jq '.[0].url') if [ -z "$PR_URL" ]; then From db6d82c9b266c303846801c9e6293781df2bfcb8 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 11:17:22 -0700 Subject: [PATCH 02/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index fdbb7dccf28f..851cdd597b9d 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -59,6 +59,9 @@ jobs: echo "Branch not yet visible to GitHub — waiting a bit more" sleep 10 } + env: + GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} + GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - name: Create or update PR run: | git branch From c1665fdc0faa3b40ea09bf0087aae5128e14f148 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 11:26:20 -0700 Subject: [PATCH 03/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 851cdd597b9d..062cb643659a 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -48,14 +48,15 @@ jobs: echo "::endgroup::" - name: Push sync branch run: | + echo "$GITHUB_TOKEN" | gh auth login --with-token git push origin sync-main-pr --force # Ensure branch is visible to GitHub - gh api repos/:owner/:repo/branches/sync-main-pr || { + gh api repos/:owner/:repo/commits/$(git rev-parse HEAD) || { echo "Branch not yet visible to GitHub — waiting a bit more" sleep 10 } git branch - gh api repos/:owner/:repo/branches/sync-main-pr || { + gh api repos/:owner/:repo/commits/$(git rev-parse HEAD) || { echo "Branch not yet visible to GitHub — waiting a bit more" sleep 10 } @@ -65,12 +66,12 @@ jobs: - name: Create or update PR run: | git branch - gh api repos/:owner/:repo/branches/sync-main-pr || { + gh api repos/:owner/:repo/commits/$(git rev-parse HEAD) || { echo "Branch not yet visible to GitHub — waiting a bit more" sleep 10 } git branch - gh api repos/:owner/:repo/branches/sync-main-pr + gh api repos/:owner/:repo/commits/$(git rev-parse HEAD) PR_URL=$(gh pr list --head sync-main-pr --json url --jq '.[0].url') if [ -z "$PR_URL" ]; then gh pr create \ From dc9fdb596e7917e3c23af3218b6b743b429cdf1a Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 11:29:26 -0700 Subject: [PATCH 04/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 062cb643659a..8da8dbac63c0 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -61,10 +61,10 @@ jobs: sleep 10 } env: - GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - name: Create or update PR run: | + echo "$GITHUB_TOKEN" | gh auth login --with-token git branch gh api repos/:owner/:repo/commits/$(git rev-parse HEAD) || { echo "Branch not yet visible to GitHub — waiting a bit more" @@ -84,6 +84,5 @@ jobs: fi exit 0 env: - GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} From b6762463f7d843c8c826748e80f32afd1419b957 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 11:33:40 -0700 Subject: [PATCH 05/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 8da8dbac63c0..6fec8696be6f 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -48,7 +48,6 @@ jobs: echo "::endgroup::" - name: Push sync branch run: | - echo "$GITHUB_TOKEN" | gh auth login --with-token git push origin sync-main-pr --force # Ensure branch is visible to GitHub gh api repos/:owner/:repo/commits/$(git rev-parse HEAD) || { @@ -60,11 +59,13 @@ jobs: echo "Branch not yet visible to GitHub — waiting a bit more" sleep 10 } + gh api repos/:owner/:repo/branches/sync-main-pr --jq . + git ls-remote origin env: + GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - name: Create or update PR run: | - echo "$GITHUB_TOKEN" | gh auth login --with-token git branch gh api repos/:owner/:repo/commits/$(git rev-parse HEAD) || { echo "Branch not yet visible to GitHub — waiting a bit more" @@ -84,5 +85,6 @@ jobs: fi exit 0 env: + GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} From 75fb343e38b2687139f87228c4e9b410f82cde1a Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 11:41:29 -0700 Subject: [PATCH 06/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 51 +++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 6fec8696be6f..6d7d30d9c644 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -46,21 +46,48 @@ jobs: git merge codeql-cli/latest set +x echo "::endgroup::" + # - name: Push sync branch + # run: | + # git push origin sync-main-pr --force + # # Ensure branch is visible to GitHub + # gh api repos/:owner/:repo/commits/$(git rev-parse HEAD) || { + # echo "Branch not yet visible to GitHub — waiting a bit more" + # sleep 10 + # } + # git branch + # gh api repos/:owner/:repo/commits/$(git rev-parse HEAD) || { + # echo "Branch not yet visible to GitHub — waiting a bit more" + # sleep 10 + # } + # gh api repos/:owner/:repo/branches/sync-main-pr --jq . + # git ls-remote origin + # env: + # GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} + # GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - name: Push sync branch run: | + # Push the branch git push origin sync-main-pr --force - # Ensure branch is visible to GitHub - gh api repos/:owner/:repo/commits/$(git rev-parse HEAD) || { - echo "Branch not yet visible to GitHub — waiting a bit more" - sleep 10 - } - git branch - gh api repos/:owner/:repo/commits/$(git rev-parse HEAD) || { - echo "Branch not yet visible to GitHub — waiting a bit more" - sleep 10 - } - gh api repos/:owner/:repo/branches/sync-main-pr --jq . - git ls-remote origin + + # Wait for the commit SHA to be indexed + COMMIT_SHA=$(git rev-parse HEAD) + MAX_RETRIES=12 + SLEEP_SECONDS=5 + for (( i=1; i<=MAX_RETRIES; i++ )); do + echo "Checking if commit $COMMIT_SHA is visible on GitHub (attempt $i)..." + if gh api repos/:owner/:repo/commits/$COMMIT_SHA > /dev/null 2>&1; then + echo "✅ Commit is now visible on GitHub." + break + else + echo "❌ Commit not yet visible — sleeping ${SLEEP_SECONDS}s" + sleep $SLEEP_SECONDS + fi + done + + if (( i > MAX_RETRIES )); then + echo "❌ Commit $COMMIT_SHA never became visible after $((MAX_RETRIES * SLEEP_SECONDS)) seconds." + exit 1 + fi env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} From d81989f345998cb89d2a7692720d13039c1a6127 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 11:48:02 -0700 Subject: [PATCH 07/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 65 ++++++++++++++------------------- 1 file changed, 27 insertions(+), 38 deletions(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 6d7d30d9c644..038a5ceb4918 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -46,72 +46,61 @@ jobs: git merge codeql-cli/latest set +x echo "::endgroup::" - # - name: Push sync branch - # run: | - # git push origin sync-main-pr --force - # # Ensure branch is visible to GitHub - # gh api repos/:owner/:repo/commits/$(git rev-parse HEAD) || { - # echo "Branch not yet visible to GitHub — waiting a bit more" - # sleep 10 - # } - # git branch - # gh api repos/:owner/:repo/commits/$(git rev-parse HEAD) || { - # echo "Branch not yet visible to GitHub — waiting a bit more" - # sleep 10 - # } - # gh api repos/:owner/:repo/branches/sync-main-pr --jq . - # git ls-remote origin - # env: - # GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - # GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - - name: Push sync branch + - name: Push sync branch and ensure visibility run: | - # Push the branch git push origin sync-main-pr --force - - # Wait for the commit SHA to be indexed + + BRANCH_NAME="sync-main-pr" COMMIT_SHA=$(git rev-parse HEAD) MAX_RETRIES=12 SLEEP_SECONDS=5 + + echo "🔄 Waiting for commit $COMMIT_SHA to be visible on GitHub..." for (( i=1; i<=MAX_RETRIES; i++ )); do - echo "Checking if commit $COMMIT_SHA is visible on GitHub (attempt $i)..." - if gh api repos/:owner/:repo/commits/$COMMIT_SHA > /dev/null 2>&1; then + if gh api "repos/:owner/:repo/commits/$COMMIT_SHA" > /dev/null 2>&1; then echo "✅ Commit is now visible on GitHub." break else - echo "❌ Commit not yet visible — sleeping ${SLEEP_SECONDS}s" + echo "⏳ Attempt $i: Commit not visible yet — sleeping ${SLEEP_SECONDS}s" sleep $SLEEP_SECONDS fi done - if (( i > MAX_RETRIES )); then echo "❌ Commit $COMMIT_SHA never became visible after $((MAX_RETRIES * SLEEP_SECONDS)) seconds." exit 1 fi + + echo "🔄 Waiting for branch '$BRANCH_NAME' to be visible on GitHub..." + for (( i=1; i<=MAX_RETRIES; i++ )); do + if gh api "repos/:owner/:repo/branches/$BRANCH_NAME" > /dev/null 2>&1; then + echo "✅ Branch is now visible on GitHub." + break + else + echo "⏳ Attempt $i: Branch not visible yet — sleeping ${SLEEP_SECONDS}s" + sleep $SLEEP_SECONDS + fi + done + if (( i > MAX_RETRIES )); then + echo "❌ Branch '$BRANCH_NAME' never became visible after $((MAX_RETRIES * SLEEP_SECONDS)) seconds." + exit 1 + fi env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - name: Create or update PR run: | - git branch - gh api repos/:owner/:repo/commits/$(git rev-parse HEAD) || { - echo "Branch not yet visible to GitHub — waiting a bit more" - sleep 10 - } - git branch - gh api repos/:owner/:repo/commits/$(git rev-parse HEAD) - PR_URL=$(gh pr list --head sync-main-pr --json url --jq '.[0].url') + BRANCH_NAME="sync-main-pr" + PR_URL=$(gh pr list --head "$BRANCH_NAME" --json url --jq '.[0].url') if [ -z "$PR_URL" ]; then + echo "📦 Creating pull request..." gh pr create \ --title "Automated sync from upstream" \ --body "This PR syncs the latest changes from \`codeql-cli/latest\` into \`main\`." \ - --head sync-main-pr \ + --head "$BRANCH_NAME" \ --base main else - echo "PR already exists: $PR_URL" + echo "✅ PR already exists: $PR_URL" fi - exit 0 env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - From ed31f43cfde7161540dc847559e401a241db088a Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 11:51:21 -0700 Subject: [PATCH 08/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 038a5ceb4918..94be7897137d 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -72,7 +72,7 @@ jobs: echo "🔄 Waiting for branch '$BRANCH_NAME' to be visible on GitHub..." for (( i=1; i<=MAX_RETRIES; i++ )); do - if gh api "repos/:owner/:repo/branches/$BRANCH_NAME" > /dev/null 2>&1; then + if git ls-remote --exit-code origin "refs/heads/$BRANCH_NAME" > /dev/null 2>&1; then echo "✅ Branch is now visible on GitHub." break else From e2bac165fef155e6c44da84d56cad353f194f944 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 11:58:41 -0700 Subject: [PATCH 09/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 94be7897137d..bbaaf8e4f424 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -48,7 +48,7 @@ jobs: echo "::endgroup::" - name: Push sync branch and ensure visibility run: | - git push origin sync-main-pr --force + git push origin sync-main-pr BRANCH_NAME="sync-main-pr" COMMIT_SHA=$(git rev-parse HEAD) From 0d40476820a3b8bc242cdf8dea20b46379d251f8 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 12:28:52 -0700 Subject: [PATCH 10/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index bbaaf8e4f424..6d4993f70f38 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -33,8 +33,13 @@ jobs: git config user.email "github-actions[bot]@users.noreply.github.com" - name: Add and fetch upstream run: | - echo "::group::Fetch and set up remotes" + echo "::group::Fetch" git fetch + git checkout main + git pull origin main + echo "::endgroup::" + + echo "::group::Set up remote" git remote add upstream https://github.com/github/codeql.git git fetch upstream --tags --force echo "::endgroup::" From 9442bf39eb98b9651d497592b1fdcd8216c1b7ea Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 12:47:13 -0700 Subject: [PATCH 11/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 6d4993f70f38..835f31f7e381 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -1,4 +1,4 @@ -name: Sync Main + name: Sync Main on: push: @@ -47,7 +47,8 @@ jobs: echo "::group::Checkout and merge" set -x git fetch origin sync-main-pr || true - git checkout -B sync-main-pr origin/main + git checkout -B sync-main-pr origin/sync-main-pr + git pull origin main git merge codeql-cli/latest set +x echo "::endgroup::" From 3324c30a71c198902cd6cab5dfe823a57c616146 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 12:48:34 -0700 Subject: [PATCH 12/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 835f31f7e381..f10ba3ef26d0 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -110,3 +110,4 @@ jobs: env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} + From d384e41953c1d525cf652648611dda6857b0b6ae Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 12:49:03 -0700 Subject: [PATCH 13/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index f10ba3ef26d0..5c0e2dd312c7 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -1,4 +1,4 @@ - name: Sync Main +name: Sync Main on: push: @@ -110,4 +110,3 @@ jobs: env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - From bc8220f76b73cfa380743e233a5cdcc26b675dc2 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 13:21:17 -0700 Subject: [PATCH 14/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 5c0e2dd312c7..9584539d7789 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -93,6 +93,11 @@ jobs: env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} + - name: Debug sync-main-pr state + run: | + git log origin/sync-main-pr..sync-main-pr + git diff origin/sync-main-pr + git status # Verify if any changes are staged - name: Create or update PR run: | BRANCH_NAME="sync-main-pr" From 71ccc9675a77adbee2d5315be5168882781dd62b Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 14:05:42 -0700 Subject: [PATCH 15/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 9584539d7789..aece1ad166a9 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -95,9 +95,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - name: Debug sync-main-pr state run: | - git log origin/sync-main-pr..sync-main-pr - git diff origin/sync-main-pr - git status # Verify if any changes are staged + git log origin/sync-main-pr..origin/main - name: Create or update PR run: | BRANCH_NAME="sync-main-pr" From 7259356af1f4b8a5b8652bc44f5a4f773a65c549 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 14:21:33 -0700 Subject: [PATCH 16/39] Update sync-main.yml From 3a630ad2762ba44bac5b329b9ed58fdca077120e Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 14:22:13 -0700 Subject: [PATCH 17/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index aece1ad166a9..3992b0617361 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -13,7 +13,6 @@ on: jobs: sync-main: - name: Sync-main runs-on: ubuntu-latest if: github.repository == 'microsoft/codeql' @@ -113,3 +112,4 @@ jobs: env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} + From d92e61eeff37b29c8c022d241bc19ee8df1f4df5 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 14:47:57 -0700 Subject: [PATCH 18/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 3992b0617361..4d40480461ce 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -30,14 +30,14 @@ jobs: run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - - name: Add and fetch upstream - run: | + git checkout -b sync-main-pr + echo "::group::Fetch" - git fetch - git checkout main - git pull origin main + git pull origin sync-main-pr; exitCode=$?; if [ $exitCode -ne 0 ]; then exitCode=0; fi + git pull --rebase origin main + git push --force origin sync-main-pr echo "::endgroup::" - + echo "::group::Set up remote" git remote add upstream https://github.com/github/codeql.git git fetch upstream --tags --force @@ -45,9 +45,6 @@ jobs: echo "::group::Checkout and merge" set -x - git fetch origin sync-main-pr || true - git checkout -B sync-main-pr origin/sync-main-pr - git pull origin main git merge codeql-cli/latest set +x echo "::endgroup::" @@ -92,23 +89,10 @@ jobs: env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - - name: Debug sync-main-pr state - run: | - git log origin/sync-main-pr..origin/main - name: Create or update PR run: | - BRANCH_NAME="sync-main-pr" - PR_URL=$(gh pr list --head "$BRANCH_NAME" --json url --jq '.[0].url') - if [ -z "$PR_URL" ]; then - echo "📦 Creating pull request..." - gh pr create \ - --title "Automated sync from upstream" \ - --body "This PR syncs the latest changes from \`codeql-cli/latest\` into \`main\`." \ - --head "$BRANCH_NAME" \ - --base main - else - echo "✅ PR already exists: $PR_URL" - fi + gh pr create --fill -B main -H sync-main-pr --title 'Sync Main' --body "This PR syncs the latest changes from \`codeql-cli/latest\` into \`main\`." + exit 0 env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} From 9a59b1c807ca3177a490e419b8d4dd5ba2219a4a Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 14:57:47 -0700 Subject: [PATCH 19/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 4d40480461ce..3b316387f077 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -30,6 +30,7 @@ jobs: run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" + git config pull.rebase true git checkout -b sync-main-pr echo "::group::Fetch" From 9bbffb6fd83b5034e69f51e94d94a8dc6841c721 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 15:09:55 -0700 Subject: [PATCH 20/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 3b316387f077..cd20f2b9a6b5 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -30,12 +30,11 @@ jobs: run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - git config pull.rebase true git checkout -b sync-main-pr echo "::group::Fetch" git pull origin sync-main-pr; exitCode=$?; if [ $exitCode -ne 0 ]; then exitCode=0; fi - git pull --rebase origin main + git pull origin main git push --force origin sync-main-pr echo "::endgroup::" From eb41d97d48adf867e06fcda4e910f09c2c061bce Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 15:28:59 -0700 Subject: [PATCH 21/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index cd20f2b9a6b5..53013783867b 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -30,10 +30,11 @@ jobs: run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - git checkout -b sync-main-pr + git checkout -B sync-main-pr origin/sync-main-pr echo "::group::Fetch" git pull origin sync-main-pr; exitCode=$?; if [ $exitCode -ne 0 ]; then exitCode=0; fi + git config pull.rebase true git pull origin main git push --force origin sync-main-pr echo "::endgroup::" From be4f1f1482b1eff28f1a88b89ae9e59c922026c0 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 15:34:53 -0700 Subject: [PATCH 22/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 53013783867b..845d8cfe5db4 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -34,7 +34,7 @@ jobs: echo "::group::Fetch" git pull origin sync-main-pr; exitCode=$?; if [ $exitCode -ne 0 ]; then exitCode=0; fi - git config pull.rebase true + # git config pull.rebase true git pull origin main git push --force origin sync-main-pr echo "::endgroup::" From 7a168b0d5c00499ccc46a90e1536aeb3bd3a1a91 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 15:37:42 -0700 Subject: [PATCH 23/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 845d8cfe5db4..0ff81e0f2744 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -51,7 +51,10 @@ jobs: echo "::endgroup::" - name: Push sync branch and ensure visibility run: | + git status + echo "yo1" git push origin sync-main-pr + echo "yo2" BRANCH_NAME="sync-main-pr" COMMIT_SHA=$(git rev-parse HEAD) From 544f0ca81da8c858765d03542f52ff4ba984dba7 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 15:43:31 -0700 Subject: [PATCH 24/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 50 ++++++++------------------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 0ff81e0f2744..3fa7549b42ce 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -51,48 +51,22 @@ jobs: echo "::endgroup::" - name: Push sync branch and ensure visibility run: | - git status - echo "yo1" git push origin sync-main-pr - echo "yo2" - - BRANCH_NAME="sync-main-pr" - COMMIT_SHA=$(git rev-parse HEAD) - MAX_RETRIES=12 - SLEEP_SECONDS=5 - - echo "🔄 Waiting for commit $COMMIT_SHA to be visible on GitHub..." - for (( i=1; i<=MAX_RETRIES; i++ )); do - if gh api "repos/:owner/:repo/commits/$COMMIT_SHA" > /dev/null 2>&1; then - echo "✅ Commit is now visible on GitHub." - break - else - echo "⏳ Attempt $i: Commit not visible yet — sleeping ${SLEEP_SECONDS}s" - sleep $SLEEP_SECONDS - fi - done - if (( i > MAX_RETRIES )); then - echo "❌ Commit $COMMIT_SHA never became visible after $((MAX_RETRIES * SLEEP_SECONDS)) seconds." - exit 1 - fi - - echo "🔄 Waiting for branch '$BRANCH_NAME' to be visible on GitHub..." - for (( i=1; i<=MAX_RETRIES; i++ )); do - if git ls-remote --exit-code origin "refs/heads/$BRANCH_NAME" > /dev/null 2>&1; then - echo "✅ Branch is now visible on GitHub." - break - else - echo "⏳ Attempt $i: Branch not visible yet — sleeping ${SLEEP_SECONDS}s" - sleep $SLEEP_SECONDS - fi - done - if (( i > MAX_RETRIES )); then - echo "❌ Branch '$BRANCH_NAME' never became visible after $((MAX_RETRIES * SLEEP_SECONDS)) seconds." - exit 1 - fi env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} + - name: Debug sync-main-pr state + run: | + echo "🔍 Checking sync-main-pr branch and its commit history" + git status + echo "Commits on sync-main-pr:" + git log --oneline sync-main-pr + echo "Commits on main:" + git log --oneline main + echo "Diff between sync-main-pr and main:" + git diff main..sync-main-pr + echo "Current SHA for main: $(git rev-parse main)" + echo "Current SHA for sync-main-pr: $(git rev-parse sync-main-pr)" - name: Create or update PR run: | gh pr create --fill -B main -H sync-main-pr --title 'Sync Main' --body "This PR syncs the latest changes from \`codeql-cli/latest\` into \`main\`." From 826d43da884e6e9719f21da82687127bed2c1fda Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 15:50:41 -0700 Subject: [PATCH 25/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 3fa7549b42ce..36d5e996a3a6 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -59,12 +59,11 @@ jobs: run: | echo "🔍 Checking sync-main-pr branch and its commit history" git status - echo "Commits on sync-main-pr:" - git log --oneline sync-main-pr - echo "Commits on main:" - git log --oneline main - echo "Diff between sync-main-pr and main:" + + echo "::group::Diff between sync-main-pr and main" git diff main..sync-main-pr + echo "::endgroup::" + echo "Current SHA for main: $(git rev-parse main)" echo "Current SHA for sync-main-pr: $(git rev-parse sync-main-pr)" - name: Create or update PR From 9f2b3eb95eeeac7594b0a4067fa6d913c5d14e08 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 15:53:16 -0700 Subject: [PATCH 26/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 36d5e996a3a6..56e5b048edfc 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -61,14 +61,14 @@ jobs: git status echo "::group::Diff between sync-main-pr and main" - git diff main..sync-main-pr + git diff origin/main..origin/sync-main-pr echo "::endgroup::" - echo "Current SHA for main: $(git rev-parse main)" - echo "Current SHA for sync-main-pr: $(git rev-parse sync-main-pr)" + echo "Current SHA for main: $(git rev-parse origin/main)" + echo "Current SHA for sync-main-pr: $(git rev-parse origin/sync-main-pr)" - name: Create or update PR run: | - gh pr create --fill -B main -H sync-main-pr --title 'Sync Main' --body "This PR syncs the latest changes from \`codeql-cli/latest\` into \`main\`." + gh pr create --fill -B origin/main -H origin/sync-main-pr --title 'Sync Main' --body "This PR syncs the latest changes from \`codeql-cli/latest\` into \`main\`." exit 0 env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} From 87d55921c6adae28c3519b963448e641bd484b8f Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 16:01:38 -0700 Subject: [PATCH 27/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 56e5b048edfc..30b67092d086 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -55,20 +55,9 @@ jobs: env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - - name: Debug sync-main-pr state - run: | - echo "🔍 Checking sync-main-pr branch and its commit history" - git status - - echo "::group::Diff between sync-main-pr and main" - git diff origin/main..origin/sync-main-pr - echo "::endgroup::" - - echo "Current SHA for main: $(git rev-parse origin/main)" - echo "Current SHA for sync-main-pr: $(git rev-parse origin/sync-main-pr)" - name: Create or update PR run: | - gh pr create --fill -B origin/main -H origin/sync-main-pr --title 'Sync Main' --body "This PR syncs the latest changes from \`codeql-cli/latest\` into \`main\`." + gh pr create --repo microsoft/codeql --fill -B main -H sync-main-pr --title 'Sync Main' --body "This PR syncs the latest changes from \`codeql-cli/latest\` into \`main\`." exit 0 env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} From d2eadbffad94347a2fa806befbaf55ee1b1c4acb Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 16:07:41 -0700 Subject: [PATCH 28/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 30b67092d086..fe5237632683 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -11,7 +11,6 @@ on: - cron: '55 * * * *' jobs: - sync-main: name: Sync-main runs-on: ubuntu-latest @@ -31,25 +30,28 @@ jobs: git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git checkout -B sync-main-pr origin/sync-main-pr - - echo "::group::Fetch" + - name: Sync origin/main + shell: bash + run: | + echo "::group::Sync with main branch" git pull origin sync-main-pr; exitCode=$?; if [ $exitCode -ne 0 ]; then exitCode=0; fi - # git config pull.rebase true git pull origin main git push --force origin sync-main-pr echo "::endgroup::" - + - name: Sync upstream/codeql-cli/latest + shell: bash + run: | echo "::group::Set up remote" git remote add upstream https://github.com/github/codeql.git git fetch upstream --tags --force echo "::endgroup::" - echo "::group::Checkout and merge" + echo "::group::Merge codeql-cli/latest" set -x git merge codeql-cli/latest set +x echo "::endgroup::" - - name: Push sync branch and ensure visibility + - name: Push sync branch run: | git push origin sync-main-pr env: From 2a8c8dbdb7beb54bc96c0f6559ea1449c59e1db5 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 16:12:47 -0700 Subject: [PATCH 29/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index fe5237632683..0c6897cafddc 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -45,7 +45,6 @@ jobs: git remote add upstream https://github.com/github/codeql.git git fetch upstream --tags --force echo "::endgroup::" - echo "::group::Merge codeql-cli/latest" set -x git merge codeql-cli/latest @@ -59,8 +58,11 @@ jobs: GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - name: Create or update PR run: | - gh pr create --repo microsoft/codeql --fill -B main -H sync-main-pr --title 'Sync Main' --body "This PR syncs the latest changes from \`codeql-cli/latest\` into \`main\`." - exit 0 + if ! gh pr view -R microsoft/codeql -t 'Sync Main' > /dev/null 2>&1; then + gh pr create --repo microsoft/codeql --fill -B main -H sync-main-pr --title 'Sync Main' --body "This PR syncs the latest changes from \`codeql-cli/latest\` into \`main\`." + else + echo "PR 'Sync Main' already exists." + fi env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} From 98338fe6c8681048c15b4684fef7d7383adb6a39 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 16:16:34 -0700 Subject: [PATCH 30/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 0c6897cafddc..19b161436677 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -58,10 +58,10 @@ jobs: GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - name: Create or update PR run: | - if ! gh pr view -R microsoft/codeql -t 'Sync Main' > /dev/null 2>&1; then - gh pr create --repo microsoft/codeql --fill -B main -H sync-main-pr --title 'Sync Main' --body "This PR syncs the latest changes from \`codeql-cli/latest\` into \`main\`." + if gh pr list --repo microsoft/codeql --head sync-main-pr --base main --json number --jq '.[0].number' > /dev/null; then + echo "PR from sync-main-pr to main already exists. Exiting gracefully." else - echo "PR 'Sync Main' already exists." + gh pr create --repo microsoft/codeql --fill -B main -H sync-main-pr --title 'Sync Main' --body "This PR syncs the latest changes from \`codeql-cli/latest\` into \`main\`." fi env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} From 3d57ea9d8c1cccaeb6a49954f7eddefabea84d84 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 16:22:18 -0700 Subject: [PATCH 31/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 19b161436677..df4aae13b59f 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -29,14 +29,14 @@ jobs: run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - git checkout -B sync-main-pr origin/sync-main-pr + git checkout -B auto/sync-main-pr origin/auto/sync-main-pr - name: Sync origin/main shell: bash run: | echo "::group::Sync with main branch" - git pull origin sync-main-pr; exitCode=$?; if [ $exitCode -ne 0 ]; then exitCode=0; fi + git pull origin auto/sync-main-pr; exitCode=$?; if [ $exitCode -ne 0 ]; then exitCode=0; fi git pull origin main - git push --force origin sync-main-pr + git push --force origin auto/sync-main-pr echo "::endgroup::" - name: Sync upstream/codeql-cli/latest shell: bash @@ -52,18 +52,15 @@ jobs: echo "::endgroup::" - name: Push sync branch run: | - git push origin sync-main-pr + git push origin auto/sync-main-pr env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - name: Create or update PR run: | - if gh pr list --repo microsoft/codeql --head sync-main-pr --base main --json number --jq '.[0].number' > /dev/null; then - echo "PR from sync-main-pr to main already exists. Exiting gracefully." + if gh pr list --repo microsoft/codeql --head auto/sync-main-pr --base main --json number --jq '.[0].number' > /dev/null; then + echo "PR from auto/sync-main-pr to main already exists. Exiting gracefully." else - gh pr create --repo microsoft/codeql --fill -B main -H sync-main-pr --title 'Sync Main' --body "This PR syncs the latest changes from \`codeql-cli/latest\` into \`main\`." + 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\`." fi env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - From a7dcc9fa6f995ca10e7b8a8606f207d0a8825947 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 16:26:10 -0700 Subject: [PATCH 32/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index df4aae13b59f..d8a9b65af27d 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -29,7 +29,18 @@ jobs: run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - git checkout -B auto/sync-main-pr origin/auto/sync-main-pr + - name: Git checkout auto/sync-main-pr + shell: bash + run: | + git fetch origin + if git ls-remote --exit-code --heads origin auto/sync-main-pr > /dev/null; then + echo "Branch exists remotely. Checking it out." + git checkout -B auto/sync-main-pr origin/auto/sync-main-pr + else + echo "Branch does not exist remotely. Creating from main." + git checkout -B auto/sync-main-pr origin/main + git push -u origin auto/sync-main-pr + fi - name: Sync origin/main shell: bash run: | From 70f9401ba2c8cf12eaf6dadf25095854926deaf0 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 16:31:56 -0700 Subject: [PATCH 33/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index d8a9b65af27d..5f1cc218632c 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -66,12 +66,18 @@ jobs: git push origin auto/sync-main-pr env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - - name: Create or update PR + - name: Create PR if it doesn't exist + shell: bash run: | - if gh pr list --repo microsoft/codeql --head auto/sync-main-pr --base main --json number --jq '.[0].number' > /dev/null; then - echo "PR from auto/sync-main-pr to main already exists. Exiting gracefully." + pr_number=$(gh pr list --repo microsoft/codeql --head auto/sync-main-pr --base main --json number --jq '.[0].number') + if [ -n "$pr_number" ]; then + echo "PR from auto/sync-main-pr to main already exists (PR #$pr_number). Exiting gracefully." else - 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\`." + 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\`." fi env: - GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 79909e93a22dfa28b3faa8cccf76f4edbeb86b97 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Tue, 8 Apr 2025 16:34:50 -0700 Subject: [PATCH 34/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 5f1cc218632c..1cb6ef032c04 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -27,8 +27,8 @@ jobs: - name: Git config shell: bash run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" + git config user.name "dilanbhalla" + git config user.email "dilanbhalla@microsoft.com" - name: Git checkout auto/sync-main-pr shell: bash run: | @@ -81,3 +81,4 @@ jobs: fi env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From a93d65b2d13cee9657fbadf63a09d45c01e43166 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Wed, 9 Apr 2025 10:11:23 -0700 Subject: [PATCH 35/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 1cb6ef032c04..43242eb90939 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -80,5 +80,4 @@ jobs: --body "This PR syncs the latest changes from \`codeql-cli/latest\` into \`main\`." fi env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} From e7edf1bab9855687e4e9344e54871c2ff66917f3 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Wed, 9 Apr 2025 10:13:45 -0700 Subject: [PATCH 36/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 43242eb90939..39b19d3879ee 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -46,7 +46,7 @@ jobs: run: | echo "::group::Sync with main branch" git pull origin auto/sync-main-pr; exitCode=$?; if [ $exitCode -ne 0 ]; then exitCode=0; fi - git pull origin main + git pull origin main --rebase git push --force origin auto/sync-main-pr echo "::endgroup::" - name: Sync upstream/codeql-cli/latest From 88a7c3a63dc07d589165b1e47c606dca12f27b59 Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Wed, 9 Apr 2025 10:16:42 -0700 Subject: [PATCH 37/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 39b19d3879ee..3f07e23244b6 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -46,7 +46,7 @@ jobs: run: | echo "::group::Sync with main branch" git pull origin auto/sync-main-pr; exitCode=$?; if [ $exitCode -ne 0 ]; then exitCode=0; fi - git pull origin main --rebase + git pull origin main --no-rebase git push --force origin auto/sync-main-pr echo "::endgroup::" - name: Sync upstream/codeql-cli/latest From b8b4e44e811b220a45a6432055814666a76472df Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Wed, 9 Apr 2025 10:24:00 -0700 Subject: [PATCH 38/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 3f07e23244b6..726d617ad1a5 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -4,7 +4,6 @@ on: push: branches: - main - - dilan/sync-main-bugs-6 paths: - .github/workflows/sync-main.yml schedule: @@ -77,7 +76,8 @@ jobs: 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\`." + --body "This PR syncs the latest changes from \`codeql-cli/latest\` into \`main\`." \ + --reviewer 'dilanbhalla, MathiasVP, ropwareJB' fi env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} From c5b024a9dd9fd82567b0e4116f4b8a889cddc86a Mon Sep 17 00:00:00 2001 From: dilanbhalla <35575727+dilanbhalla@users.noreply.github.com> Date: Wed, 9 Apr 2025 10:26:10 -0700 Subject: [PATCH 39/39] Update sync-main.yml --- .github/workflows/sync-main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index 726d617ad1a5..87ad2d834460 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -77,7 +77,8 @@ jobs: --label 'autogenerated' \ --title 'Sync Main (autogenerated)' \ --body "This PR syncs the latest changes from \`codeql-cli/latest\` into \`main\`." \ - --reviewer 'dilanbhalla, MathiasVP, ropwareJB' + --reviewer 'MathiasVP' + --reviewer 'ropwareJB' fi env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}