Skip to content

Commit 75fb343

Browse files
authored
Update sync-main.yml
1 parent b676246 commit 75fb343

1 file changed

Lines changed: 39 additions & 12 deletions

File tree

.github/workflows/sync-main.yml

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,48 @@ 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 }}
4967
- name: Push sync branch
5068
run: |
69+
# Push the branch
5170
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
71+
72+
# Wait for the commit SHA to be indexed
73+
COMMIT_SHA=$(git rev-parse HEAD)
74+
MAX_RETRIES=12
75+
SLEEP_SECONDS=5
76+
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
79+
echo "✅ Commit is now visible on GitHub."
80+
break
81+
else
82+
echo "❌ Commit not yet visible — sleeping ${SLEEP_SECONDS}s"
83+
sleep $SLEEP_SECONDS
84+
fi
85+
done
86+
87+
if (( i > MAX_RETRIES )); then
88+
echo "❌ Commit $COMMIT_SHA never became visible after $((MAX_RETRIES * SLEEP_SECONDS)) seconds."
89+
exit 1
90+
fi
6491
env:
6592
GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
6693
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}

0 commit comments

Comments
 (0)