1
1
name : Sync Main
2
+
2
3
on :
3
4
schedule :
4
5
- cron : ' 55 * * * *'
6
+
5
7
jobs :
8
+
6
9
sync-main :
10
+
7
11
name : Sync-main
8
12
runs-on : ubuntu-latest
9
13
if : github.repository == 'microsoft/codeql'
10
14
permissions :
11
15
contents : write
16
+ pull-requests : write
17
+
12
18
steps :
13
19
- name : Checkout
14
20
uses : actions/checkout@v3
@@ -18,16 +24,17 @@ jobs:
18
24
- name : Git config
19
25
shell : bash
20
26
run : |
21
- git config user.name Dilan Bhalla
22
- git config user.email [email protected]
23
- - name : Sync Main
24
- shell : bash
27
+ git config user.name "github-actions[bot]"
28
+ git config user.email "github-actions[bot]@users.noreply.github.com"
29
+ - name : Add and fetch upstream
25
30
run : |
26
- set -x
27
- git fetch
28
31
git remote add upstream https://github.com/github/codeql.git
29
32
git fetch upstream --tags --force
30
- git merge codeql-cli/latest
33
+ - name : Create or reset sync branch
34
+ run : |
35
+ git fetch origin sync-main-pr || true
36
+ git checkout -B sync-main-pr origin/main
37
+ git merge upstream/codeql-cli/latest --no-edit || true
31
38
- name : Setup CodeQL
32
39
shell : bash
33
40
run : |
41
48
- name : Compile PowerShell Queries
42
49
run : |
43
50
codeql query compile --check-only --keep-going powershell/ql/src
44
- - name : Complete Sync
45
- shell : bash
51
+ - name : Push sync branch
46
52
run : |
47
- git push origin main
48
- git push origin --tags --force
49
-
53
+ git push origin sync-main-pr --force
54
+ - name : Create or update PR
55
+ run : |
56
+ PR_URL=$(gh pr list --head sync-main-pr --json url --jq '.[0].url')
57
+ if [ -z "$PR_URL" ]; then
58
+ gh pr create \
59
+ --title "Automated sync from upstream" \
60
+ --body "This PR syncs the latest changes from \`codeql-cli/latest\` into \`main\`." \
61
+ --head sync-main-pr \
62
+ --base main
63
+ else
64
+ echo "PR already exists: $PR_URL"
65
+ fi
66
+ env :
67
+ GITHUB_TOKEN : ${{ github.token }}
0 commit comments