mirror of
https://github.com/github/codeql.git
synced 2026-05-25 00:27:09 +02:00
101 lines
3.3 KiB
YAML
101 lines
3.3 KiB
YAML
name: Sync Main
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- dilan/sync-main-bugs-6
|
|
paths:
|
|
- .github/workflows/sync-main.yml
|
|
schedule:
|
|
- cron: '55 * * * *'
|
|
|
|
jobs:
|
|
|
|
sync-main:
|
|
name: Sync-main
|
|
runs-on: ubuntu-latest
|
|
if: github.repository == 'microsoft/codeql'
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
- 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 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::"
|
|
|
|
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"
|
|
set -x
|
|
git merge codeql-cli/latest
|
|
set +x
|
|
echo "::endgroup::"
|
|
- name: Push sync branch and ensure visibility
|
|
run: |
|
|
git push origin sync-main-pr
|
|
|
|
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: 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\`."
|
|
exit 0
|
|
env:
|
|
GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
|
|
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
|
|
|