summary refs log tree commit diff
path: root/.github
diff options
context:
space:
mode:
authorSilvan Mosberger <silvan.mosberger@tweag.io>2023-10-05 00:00:24 +0200
committerSilvan Mosberger <silvan.mosberger@tweag.io>2023-10-05 00:13:47 +0200
commit004da0cf9140d016904a4f0087c3c5b96ecef0ab (patch)
treef10fd1037350b2cf56f7a9a7a3fd9c8325db6d5c /.github
parentc1a36c3baa9b0901878708c859979f43c15bd92a (diff)
downloadnixpkgs-004da0cf9140d016904a4f0087c3c5b96ecef0ab.tar
nixpkgs-004da0cf9140d016904a4f0087c3c5b96ecef0ab.tar.gz
nixpkgs-004da0cf9140d016904a4f0087c3c5b96ecef0ab.tar.bz2
nixpkgs-004da0cf9140d016904a4f0087c3c5b96ecef0ab.tar.lz
nixpkgs-004da0cf9140d016904a4f0087c3c5b96ecef0ab.tar.xz
nixpkgs-004da0cf9140d016904a4f0087c3c5b96ecef0ab.tar.zst
nixpkgs-004da0cf9140d016904a4f0087c3c5b96ecef0ab.zip
workflows/check-by-name: Better error for merge conflicts
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/check-by-name.yml14
1 files changed, 11 insertions, 3 deletions
diff --git a/.github/workflows/check-by-name.yml b/.github/workflows/check-by-name.yml
index faf0eb47517..3c515e45189 100644
--- a/.github/workflows/check-by-name.yml
+++ b/.github/workflows/check-by-name.yml
@@ -17,16 +17,24 @@ jobs:
     # as specified in nixos/release-combined.nix
     runs-on: ubuntu-latest
     steps:
+      - name: Resolving the merge commit
+        run: |
+          if result=$(git ls-remote --exit-code ${{ github.event.pull_request.base.repo.clone_url }} refs/pull/${{ github.event.pull_request.number }}/merge); then
+            mergedSha=$(cut -f1 <<< "$result")
+            echo "The PR appears to not have any conflicts, checking the merge commit $mergedSha"
+          else
+            echo "The PR may have a merge conflict"
+            exit 1
+          fi
+          echo "mergedSha=$mergedSha" >> "$GITHUB_ENV"
       - uses: actions/checkout@v4
         with:
           # pull_request_target checks out the base branch by default
-          ref: refs/pull/${{ github.event.pull_request.number }}/merge
+          ref: ${{ env.mergedSha }}
           # Fetches the merge commit and its parents
           fetch-depth: 2
       - name: Determining PR git hashes
         run: |
-          echo "mergedSha=$(git rev-parse HEAD)" >> "$GITHUB_ENV"
-
           # For pull_request_target this is the same as $GITHUB_SHA
           echo "baseSha=$(git rev-parse HEAD^1)" >> "$GITHUB_ENV"