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