[CI] Add include_high_priority checkbox to cancel workflow (#21363)

This commit is contained in:
Liangsheng Yin
2026-03-24 21:30:44 -07:00
committed by GitHub
parent 92492896a5
commit c769398748
@@ -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