mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-14 06:00:33 +03:00
workflows/check-by-name: Cancel on merge conflicts
This commit is contained in:
parent
d17c5a31dc
commit
dbb599f2e4
1 changed files with 11 additions and 3 deletions
14
.github/workflows/check-by-name.yml
vendored
14
.github/workflows/check-by-name.yml
vendored
|
@ -8,8 +8,9 @@ on:
|
||||||
# Using pull_request_target instead of pull_request avoids having to approve first time contributors
|
# Using pull_request_target instead of pull_request avoids having to approve first time contributors
|
||||||
pull_request_target
|
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:
|
jobs:
|
||||||
check:
|
check:
|
||||||
|
@ -62,7 +63,14 @@ jobs:
|
||||||
if [[ "$mergeable" == "true" ]]; then
|
if [[ "$mergeable" == "true" ]]; then
|
||||||
echo "The PR can be merged, checking the merge commit $mergedSha"
|
echo "The PR can be merged, checking the merge commit $mergedSha"
|
||||||
else
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "mergedSha=$mergedSha" >> "$GITHUB_ENV"
|
echo "mergedSha=$mergedSha" >> "$GITHUB_ENV"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue