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
@@ -30,13 +31,18 @@ jobs:
30
31
--remove-label "Rebuild"
31
32
32
33
- name : Merge in changes from base branch
34
+ id : merge
33
35
env :
34
36
BASE_BRANCH : ${{ github.event.pull_request.base.ref || 'main' }}
35
37
run : |
36
38
git fetch origin "$BASE_BRANCH"
37
39
38
40
# Allow merge conflicts in `lib`, since rebuilding should resolve them.
39
- git merge "origin/$BASE_BRANCH" || echo "Merge conflicts detected, continuing..."
41
+ git merge "origin/$BASE_BRANCH" || MERGE_RESULT=$?
42
+
43
+ if [ -n "$MERGE_RESULT" ]; then
44
+ echo "merge-in-progress=true" >> $GITHUB_OUTPUT
45
+ fi
40
46
41
47
# Check for merge conflicts outside of `lib`. Disable git diff's trailing whitespace check
42
48
# since `node_modules/@types/semver/README.md` fails it.
@@ -67,13 +73,25 @@ jobs:
67
73
pip install ruamel.yaml==0.17.31
68
74
python3 sync.py
69
75
70
- - name : Check for changes and push
76
+ - name : Configure git
77
+ run : |
78
+ git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
79
+ git config --global user.name "github-actions[bot]"
80
+
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