Skip to content

Commit 4175311

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

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

.github/workflows/rebuild.yml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
- name: Checkout
1919
uses: actions/checkout@v4
2020
with:
21+
fetch-depth: 0
2122
ref: ${{ github.event.pull_request.head.ref || github.event.ref }}
2223

2324
- name: Remove label
@@ -30,13 +31,18 @@ jobs:
3031
--remove-label "Rebuild"
3132
3233
- name: Merge in changes from base branch
34+
id: merge
3335
env:
3436
BASE_BRANCH: ${{ github.event.pull_request.base.ref || 'main' }}
3537
run: |
3638
git fetch origin "$BASE_BRANCH"
3739
3840
# 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
4046
4147
# Check for merge conflicts outside of `lib`. Disable git diff's trailing whitespace check
4248
# since `node_modules/@types/semver/README.md` fails it.
@@ -67,13 +73,25 @@ jobs:
6773
pip install ruamel.yaml==0.17.31
6874
python3 sync.py
6975
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'
7191
id: push
7292
run: |
7393
if [ ! -z "$(git status --porcelain)" ]; then
7494
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]"
7795
git add --all
7896
# If the merge originally had conflicts, finish the merge.
7997
# Otherwise, just commit the changes.
@@ -92,7 +110,12 @@ jobs:
92110
fi
93111
94112
- 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+
)
96119
env:
97120
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98121
PR_NUMBER: ${{ github.event.pull_request.number }}

0 commit comments

Comments
 (0)