Merge pull request #259074 from tweag/detect-merge-conflicts

workflows/check-by-name: Better error for merge conflicts

authored by Silvan Mosberger and committed by GitHub b3e14b90 fbe36304

+11 -3
+11 -3
.github/workflows/check-by-name.yml
··· 17 17 # as specified in nixos/release-combined.nix 18 18 runs-on: ubuntu-latest 19 19 steps: 20 + - name: Resolving the merge commit 21 + run: | 22 + if result=$(git ls-remote --exit-code ${{ github.event.pull_request.base.repo.clone_url }} refs/pull/${{ github.event.pull_request.number }}/merge); then 23 + mergedSha=$(cut -f1 <<< "$result") 24 + echo "The PR appears to not have any conflicts, checking the merge commit $mergedSha" 25 + else 26 + echo "The PR may have a merge conflict" 27 + exit 1 28 + fi 29 + echo "mergedSha=$mergedSha" >> "$GITHUB_ENV" 20 30 - uses: actions/checkout@v4 21 31 with: 22 32 # pull_request_target checks out the base branch by default 23 - ref: refs/pull/${{ github.event.pull_request.number }}/merge 33 + ref: ${{ env.mergedSha }} 24 34 # Fetches the merge commit and its parents 25 35 fetch-depth: 2 26 36 - name: Determining PR git hashes 27 37 run: | 28 - echo "mergedSha=$(git rev-parse HEAD)" >> "$GITHUB_ENV" 29 - 30 38 # For pull_request_target this is the same as $GITHUB_SHA 31 39 echo "baseSha=$(git rev-parse HEAD^1)" >> "$GITHUB_ENV" 32 40