diff --git a/.github/workflows/cancel-unfinished-pr-tests.yml b/.github/workflows/cancel-unfinished-pr-tests.yml index 2c0e9f63f..6aa714afb 100644 --- a/.github/workflows/cancel-unfinished-pr-tests.yml +++ b/.github/workflows/cancel-unfinished-pr-tests.yml @@ -8,6 +8,11 @@ on: required: true type: string default: 'pr-test.yml' + include_high_priority: + description: 'Also cancel runs from high-priority PRs' + required: false + type: boolean + default: false permissions: actions: write # Needed to cancel runs @@ -26,6 +31,7 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPO: ${{ github.repository }} WORKFLOWS: ${{ github.event.inputs.workflows || 'pr-test.yml' }} + INCLUDE_HIGH_PRIORITY: ${{ github.event.inputs.include_high_priority || 'false' }} shell: bash run: | set -euo pipefail @@ -123,11 +129,19 @@ jobs: labels=$(gh pr view "$pr_number" --repo "$REPO" --json labels \ | jq -r '.labels[].name' 2>/dev/null || true) - if echo "$labels" | grep -Fxq "high priority"; then - echo " 🛑 Skipping (high priority label)" + if echo "$labels" | grep -Fxq "ci maintain"; then + echo " 🛑 Skipping (ci maintain label, never cancelled)" continue fi + if echo "$labels" | grep -Fxq "high priority"; then + if [ "$INCLUDE_HIGH_PRIORITY" != "true" ]; then + echo " 🛑 Skipping (high priority label)" + continue + fi + echo " ⚠️ High priority PR, but include_high_priority is enabled" + fi + echo " 🚫 Cancelling..." gh run cancel "$run_id" --repo "$REPO" || echo " ⚠️ Cancellation failed" done