about summary refs log tree commit diff
path: root/nixpkgs/.github/workflows
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2023-12-17 17:44:14 +0100
committerAlyssa Ross <hi@alyssa.is>2023-12-17 17:44:14 +0100
commit778336429cc37ad5b0d736336141d09bf227653d (patch)
tree4aa85bd5d87d5bb5fb2c35ab9313987606abca89 /nixpkgs/.github/workflows
parent6b8e2555ef013b579cda57025b17d662e0f1fe1f (diff)
parent7d6929828a2d28eda9d37254ff6be3b6819506ca (diff)
downloadnixlib-778336429cc37ad5b0d736336141d09bf227653d.tar
nixlib-778336429cc37ad5b0d736336141d09bf227653d.tar.gz
nixlib-778336429cc37ad5b0d736336141d09bf227653d.tar.bz2
nixlib-778336429cc37ad5b0d736336141d09bf227653d.tar.lz
nixlib-778336429cc37ad5b0d736336141d09bf227653d.tar.xz
nixlib-778336429cc37ad5b0d736336141d09bf227653d.tar.zst
nixlib-778336429cc37ad5b0d736336141d09bf227653d.zip
Merge branch 'nixos-unstable-small' of https://github.com/NixOS/nixpkgs
Diffstat (limited to 'nixpkgs/.github/workflows')
-rw-r--r--nixpkgs/.github/workflows/check-by-name.yml14
1 files changed, 11 insertions, 3 deletions
diff --git a/nixpkgs/.github/workflows/check-by-name.yml b/nixpkgs/.github/workflows/check-by-name.yml
index 294775fa1c8e..5e3e65641f82 100644
--- a/nixpkgs/.github/workflows/check-by-name.yml
+++ b/nixpkgs/.github/workflows/check-by-name.yml
@@ -8,8 +8,9 @@ on:
   # Using pull_request_target instead of pull_request avoids having to approve first time contributors
   pull_request_target
 
-# The tool doesn't need any permissions, it only outputs success or not based on the checkout
-permissions: {}
+permissions:
+  # We need this permission to cancel the workflow run if there's a merge conflict
+  actions: write
 
 jobs:
   check:
@@ -62,7 +63,14 @@ jobs:
           if [[ "$mergeable" == "true" ]]; then
             echo "The PR can be merged, checking the merge commit $mergedSha"
           else
-            echo "The PR cannot be merged, it has a merge conflict"
+            echo "The PR cannot be merged, it has a merge conflict, cancelling the workflow.."
+            gh api \
+              --method POST \
+              -H "Accept: application/vnd.github+json" \
+              -H "X-GitHub-Api-Version: 2022-11-28" \
+              /repos/"$GITHUB_REPOSITORY"/actions/runs/"$GITHUB_RUN_ID"/cancel
+            sleep 60
+            # If it's still not canceled after a minute, something probably went wrong, just exit
             exit 1
           fi
           echo "mergedSha=$mergedSha" >> "$GITHUB_ENV"