From 56b0d5f02c15aec22d79bfd6e21d4f7829742b54 Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Fri, 2 Oct 2026 16:06:52 +0100 Subject: [PATCH] Fix the rebuild workflow failing when merging the base branch conflicts Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/rebuild.yml | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/rebuild.yml b/.github/workflows/rebuild.yml index 9daf5e6e8..c9522bf9a 100644 --- a/.github/workflows/rebuild.yml +++ b/.github/workflows/rebuild.yml @@ -54,20 +54,12 @@ jobs: run: | git fetch origin "$BASE_BRANCH" - # Allow merge conflicts in `lib`, since rebuilding should resolve them. - git merge "origin/$BASE_BRANCH" - MERGE_RESULT=$? - - if [ "$MERGE_RESULT" -eq 0 ]; then + # Allow merge conflicts in `lib`, since rebuilding should resolve them. Conflicts leave the + # merge in progress, so check for `MERGE_HEAD` to tell them apart from failures that don't. + if git merge "origin/$BASE_BRANCH"; then echo "Merge succeeded cleanly." - elif [ "$MERGE_RESULT" -eq 1 ]; then - echo "Merge conflicts detected (exit code $MERGE_RESULT), continuing." - else - echo "git merge failed with unexpected exit code $MERGE_RESULT." - exit 1 - fi - - if [ "$MERGE_RESULT" -ne 0 ]; then + elif git rev-parse --verify MERGE_HEAD >/dev/null 2>&1; then + echo "Merge conflicts detected, continuing." echo "merge-in-progress=true" >> $GITHUB_OUTPUT # Check for merge conflicts outside of `lib`. @@ -80,6 +72,9 @@ jobs: echo "No merge conflicts found outside the lib directory. We should be able to resolve all of" \ "these by rebuilding the Action." + else + echo "git merge failed for a reason other than merge conflicts." + exit 1 fi - name: Compile TypeScript