@@ -30,24 +30,21 @@ jobs:
3030 run : |
3131 git config user.name "github-actions[bot]"
3232 git config user.email "github-actions[bot]@users.noreply.github.com"
33- - name : Add and fetch upstream
34- run : |
33+ git checkout -b sync-main-pr
34+
3535 echo "::group::Fetch"
36- git fetch
37- git checkout main
38- git pull origin main
36+ git pull origin sync-main-pr; exitCode=$?; if [ $exitCode -ne 0 ]; then exitCode=0; fi
37+ git pull --rebase origin main
38+ git push --force origin sync- main-pr
3939 echo "::endgroup::"
40-
40+
4141 echo "::group::Set up remote"
4242 git remote add upstream https://github.com/github/codeql.git
4343 git fetch upstream --tags --force
4444 echo "::endgroup::"
4545
4646 echo "::group::Checkout and merge"
4747 set -x
48- git fetch origin sync-main-pr || true
49- git checkout -B sync-main-pr origin/sync-main-pr
50- git pull origin main
5148 git merge codeql-cli/latest
5249 set +x
5350 echo "::endgroup::"
@@ -92,23 +89,10 @@ jobs:
9289 env :
9390 GH_TOKEN : ${{ secrets.WORKFLOW_TOKEN }}
9491 GITHUB_TOKEN : ${{ secrets.WORKFLOW_TOKEN }}
95- - name : Debug sync-main-pr state
96- run : |
97- git log origin/sync-main-pr..origin/main
9892 - name : Create or update PR
9993 run : |
100- BRANCH_NAME="sync-main-pr"
101- PR_URL=$(gh pr list --head "$BRANCH_NAME" --json url --jq '.[0].url')
102- if [ -z "$PR_URL" ]; then
103- echo "📦 Creating pull request..."
104- gh pr create \
105- --title "Automated sync from upstream" \
106- --body "This PR syncs the latest changes from \`codeql-cli/latest\` into \`main\`." \
107- --head "$BRANCH_NAME" \
108- --base main
109- else
110- echo "✅ PR already exists: $PR_URL"
111- fi
94+ 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\`."
95+ exit 0
11296 env :
11397 GH_TOKEN : ${{ secrets.WORKFLOW_TOKEN }}
11498 GITHUB_TOKEN : ${{ secrets.WORKFLOW_TOKEN }}
0 commit comments