Skip to content

Commit 3df0b96

Browse files
committed
Finish in-progress merges
1 parent 2afb4e6 commit 3df0b96

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

.github/workflows/rebuild.yml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,18 @@ jobs:
3030
--remove-label "Rebuild"
3131
3232
- name: Merge in changes from base branch
33+
id: merge
3334
env:
3435
BASE_BRANCH: ${{ github.event.pull_request.base.ref || 'main' }}
3536
run: |
3637
git fetch origin "$BASE_BRANCH"
3738
3839
# Allow merge conflicts in `lib`, since rebuilding should resolve them.
39-
git merge "origin/$BASE_BRANCH" || echo "Merge conflicts detected, continuing..."
40+
git merge "origin/$BASE_BRANCH" || MERGE_RESULT=$?
41+
42+
if [ -n "$MERGE_RESULT" ]; then
43+
echo "merge-in-progress=true" >> $GITHUB_OUTPUT
44+
fi
4045
4146
# Check for merge conflicts outside of `lib`. Disable git diff's trailing whitespace check
4247
# since `node_modules/@types/semver/README.md` fails it.
@@ -67,13 +72,25 @@ jobs:
6772
pip install ruamel.yaml==0.17.31
6873
python3 sync.py
6974
70-
- name: Check for changes and push
75+
- name: Configure git
76+
run: |
77+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
78+
git config --global user.name "github-actions[bot]"
79+
80+
- name: "Merge in progress: Finish merge and push"
81+
if: steps.merge.outputs.merge-in-progress == 'true'
82+
run: |
83+
echo "Finishing merge and pushing changes."
84+
git add --all
85+
git commit --no-edit
86+
git push
87+
88+
- name: "No merge in progress: Check for changes and push"
89+
if: steps.merge.outputs.merge-in-progress != 'true'
7190
id: push
7291
run: |
7392
if [ ! -z "$(git status --porcelain)" ]; then
7493
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]"
7794
git add --all
7895
# If the merge originally had conflicts, finish the merge.
7996
# Otherwise, just commit the changes.
@@ -92,7 +109,12 @@ jobs:
92109
fi
93110
94111
- name: Notify about rebuild
95-
if: github.event_name == 'pull_request' && steps.push.outputs.changes == 'true'
112+
if: >-
113+
github.event_name == 'pull_request' &&
114+
(
115+
steps.merge.outputs.merge-in-progress == 'true' ||
116+
steps.push.outputs.changes == 'true'
117+
)
96118
env:
97119
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98120
PR_NUMBER: ${{ github.event.pull_request.number }}

0 commit comments

Comments
 (0)