diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8e8667e107..938eff9728 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,7 +59,8 @@ jobs: - uses: actions/checkout@v4 with: ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }} - fetch-depth: ${{ github.event_name == 'pull_request_target' && 0 || 1 }} + # Full history: the merge below needs it (a shallow clone refuses to merge at all). + fetch-depth: 0 # The pull request as it would be once merged onto main is what gets built. When it cannot # be merged, the conflicting files and the conflicting hunks go into the run summary and the @@ -83,6 +84,19 @@ jobs: exit 0 fi FILES=$(git diff --name-only --diff-filter=U) + if [ -z "$FILES" ]; then + # The merge did not even start (git said why): quote it rather than list nothing. + { + echo "### ❌ Could not merge onto main (\`$BASE\`)" + echo + echo '```' + cat /tmp/merge.out + echo '```' + } > /tmp/pr-merge.md + cat /tmp/pr-merge.md >> "$GITHUB_STEP_SUMMARY" + echo "::error::git could not merge main: $(head -3 /tmp/merge.out | tr '\n' ' ')" + exit 1 + fi { echo "### ❌ Not mergeable — conflicts with main (\`$BASE\`)" echo