diff --git a/.github/workflows/staging-aggregate.yaml b/.github/workflows/staging-aggregate.yaml index 74d2ff66b49..2d383806ae9 100644 --- a/.github/workflows/staging-aggregate.yaml +++ b/.github/workflows/staging-aggregate.yaml @@ -207,6 +207,12 @@ jobs: continue fi + # Check the PR out first, so that all its files are here before the merge. If some + # are missing, git can ask the server for files the merge itself has just written, + # and fail ("upload-pack: not our ref"). + git checkout -q --detach "$MERGE_REF" || echo "::warning::Loading the files of PR #$pr failed" + git checkout -q -f "$AGGREGATE_BRANCH" + # Try to merge into our aggregate branch if git merge "$MERGE_REF" --no-edit; then echo "✅ Successfully merged PR #$pr" @@ -221,6 +227,9 @@ jobs: git merge --abort else echo "::warning::Merging PR #$pr failed before conflict resolution (not a content conflict) - skipping" + # Such a merge can leave half-changed files behind, which the build would pick up. + git reset -q --hard + git clean -fdq fi fi done