18
18
- name : Checkout
19
19
uses : actions/checkout@v4
20
20
with :
21
+ fetch-depth : 0
21
22
ref : ${{ github.event.pull_request.head.ref || github.event.ref }}
22
23
23
24
- name : Remove label
@@ -29,14 +30,24 @@ jobs:
29
30
gh pr edit --repo github/codeql-action "$PR_NUMBER" \
30
31
--remove-label "Rebuild"
31
32
33
+ - name : Configure git
34
+ run : |
35
+ git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
36
+ git config --global user.name "github-actions[bot]"
37
+
32
38
- name : Merge in changes from base branch
39
+ id : merge
33
40
env :
34
41
BASE_BRANCH : ${{ github.event.pull_request.base.ref || 'main' }}
35
42
run : |
36
43
git fetch origin "$BASE_BRANCH"
37
44
38
45
# Allow merge conflicts in `lib`, since rebuilding should resolve them.
39
- git merge "origin/$BASE_BRANCH" || echo "Merge conflicts detected, continuing..."
46
+ git merge "origin/$BASE_BRANCH" || MERGE_RESULT=$?
47
+
48
+ if [ -n "$MERGE_RESULT" ]; then
49
+ echo "merge-in-progress=true" >> $GITHUB_OUTPUT
50
+ fi
40
51
41
52
# Check for merge conflicts outside of `lib`. Disable git diff's trailing whitespace check
42
53
# since `node_modules/@types/semver/README.md` fails it.
@@ -67,13 +78,20 @@ jobs:
67
78
pip install ruamel.yaml==0.17.31
68
79
python3 sync.py
69
80
70
- - name : Check for changes and push
81
+ - name : " Merge in progress: Finish merge and push"
82
+ if : steps.merge.outputs.merge-in-progress == 'true'
83
+ run : |
84
+ echo "Finishing merge and pushing changes."
85
+ git add --all
86
+ git commit --no-edit
87
+ git push
88
+
89
+ - name : " No merge in progress: Check for changes and push"
90
+ if : steps.merge.outputs.merge-in-progress != 'true'
71
91
id : push
72
92
run : |
73
93
if [ ! -z "$(git status --porcelain)" ]; then
74
94
echo "Changes detected, committing and pushing."
75
- git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
76
- git config --global user.name "github-actions[bot]"
77
95
git add --all
78
96
# If the merge originally had conflicts, finish the merge.
79
97
# Otherwise, just commit the changes.
@@ -92,7 +110,12 @@ jobs:
92
110
fi
93
111
94
112
- name : Notify about rebuild
95
- if : github.event_name == 'pull_request' && steps.push.outputs.changes == 'true'
113
+ if : >-
114
+ github.event_name == 'pull_request' &&
115
+ (
116
+ steps.merge.outputs.merge-in-progress == 'true' ||
117
+ steps.push.outputs.changes == 'true'
118
+ )
96
119
env :
97
120
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
98
121
PR_NUMBER : ${{ github.event.pull_request.number }}
0 commit comments