@@ -46,72 +46,61 @@ jobs:
4646 git merge codeql-cli/latest
4747 set +x
4848 echo "::endgroup::"
49- # - name: Push sync branch
50- # run: |
51- # git push origin sync-main-pr --force
52- # # Ensure branch is visible to GitHub
53- # gh api repos/:owner/:repo/commits/$(git rev-parse HEAD) || {
54- # echo "Branch not yet visible to GitHub — waiting a bit more"
55- # sleep 10
56- # }
57- # git branch
58- # gh api repos/:owner/:repo/commits/$(git rev-parse HEAD) || {
59- # echo "Branch not yet visible to GitHub — waiting a bit more"
60- # sleep 10
61- # }
62- # gh api repos/:owner/:repo/branches/sync-main-pr --jq .
63- # git ls-remote origin
64- # env:
65- # GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
66- # GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
67- - name : Push sync branch
49+ - name : Push sync branch and ensure visibility
6850 run : |
69- # Push the branch
7051 git push origin sync-main-pr --force
71-
72- # Wait for the commit SHA to be indexed
52+
53+ BRANCH_NAME="sync-main-pr"
7354 COMMIT_SHA=$(git rev-parse HEAD)
7455 MAX_RETRIES=12
7556 SLEEP_SECONDS=5
57+
58+ echo "🔄 Waiting for commit $COMMIT_SHA to be visible on GitHub..."
7659 for (( i=1; i<=MAX_RETRIES; i++ )); do
77- echo "Checking if commit $COMMIT_SHA is visible on GitHub (attempt $i)..."
78- if gh api repos/:owner/:repo/commits/$COMMIT_SHA > /dev/null 2>&1; then
60+ if gh api "repos/:owner/:repo/commits/$COMMIT_SHA" > /dev/null 2>&1; then
7961 echo "✅ Commit is now visible on GitHub."
8062 break
8163 else
82- echo "❌ Commit not yet visible — sleeping ${SLEEP_SECONDS}s"
64+ echo "⏳ Attempt $i: Commit not visible yet — sleeping ${SLEEP_SECONDS}s"
8365 sleep $SLEEP_SECONDS
8466 fi
8567 done
86-
8768 if (( i > MAX_RETRIES )); then
8869 echo "❌ Commit $COMMIT_SHA never became visible after $((MAX_RETRIES * SLEEP_SECONDS)) seconds."
8970 exit 1
9071 fi
72+
73+ echo "🔄 Waiting for branch '$BRANCH_NAME' to be visible on GitHub..."
74+ for (( i=1; i<=MAX_RETRIES; i++ )); do
75+ if gh api "repos/:owner/:repo/branches/$BRANCH_NAME" > /dev/null 2>&1; then
76+ echo "✅ Branch is now visible on GitHub."
77+ break
78+ else
79+ echo "⏳ Attempt $i : Branch not visible yet — sleeping ${SLEEP_SECONDS}s"
80+ sleep $SLEEP_SECONDS
81+ fi
82+ done
83+ if (( i > MAX_RETRIES )); then
84+ echo "❌ Branch '$BRANCH_NAME' never became visible after $((MAX_RETRIES * SLEEP_SECONDS)) seconds."
85+ exit 1
86+ fi
9187 env :
9288 GH_TOKEN : ${{ secrets.WORKFLOW_TOKEN }}
9389 GITHUB_TOKEN : ${{ secrets.WORKFLOW_TOKEN }}
9490 - name : Create or update PR
9591 run : |
96- git branch
97- gh api repos/:owner/:repo/commits/$(git rev-parse HEAD) || {
98- echo "Branch not yet visible to GitHub — waiting a bit more"
99- sleep 10
100- }
101- git branch
102- gh api repos/:owner/:repo/commits/$(git rev-parse HEAD)
103- PR_URL=$(gh pr list --head sync-main-pr --json url --jq '.[0].url')
92+ BRANCH_NAME="sync-main-pr"
93+ PR_URL=$(gh pr list --head "$BRANCH_NAME" --json url --jq '.[0].url')
10494 if [ -z "$PR_URL" ]; then
95+ echo "📦 Creating pull request..."
10596 gh pr create \
10697 --title "Automated sync from upstream" \
10798 --body "This PR syncs the latest changes from \`codeql-cli/latest\` into \`main\`." \
108- --head sync-main-pr \
99+ --head "$BRANCH_NAME" \
109100 --base main
110101 else
111- echo "PR already exists: $PR_URL"
102+ echo "✅ PR already exists: $PR_URL"
112103 fi
113- exit 0
114104 env :
115105 GH_TOKEN : ${{ secrets.WORKFLOW_TOKEN }}
116106 GITHUB_TOKEN : ${{ secrets.WORKFLOW_TOKEN }}
117-
0 commit comments