[CI] Add include_high_priority checkbox to cancel workflow (#21363)
This commit is contained in:
@@ -8,6 +8,11 @@ on:
|
|||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
default: 'pr-test.yml'
|
default: 'pr-test.yml'
|
||||||
|
include_high_priority:
|
||||||
|
description: 'Also cancel runs from high-priority PRs'
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
actions: write # Needed to cancel runs
|
actions: write # Needed to cancel runs
|
||||||
@@ -26,6 +31,7 @@ jobs:
|
|||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
REPO: ${{ github.repository }}
|
REPO: ${{ github.repository }}
|
||||||
WORKFLOWS: ${{ github.event.inputs.workflows || 'pr-test.yml' }}
|
WORKFLOWS: ${{ github.event.inputs.workflows || 'pr-test.yml' }}
|
||||||
|
INCLUDE_HIGH_PRIORITY: ${{ github.event.inputs.include_high_priority || 'false' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
@@ -123,10 +129,18 @@ jobs:
|
|||||||
labels=$(gh pr view "$pr_number" --repo "$REPO" --json labels \
|
labels=$(gh pr view "$pr_number" --repo "$REPO" --json labels \
|
||||||
| jq -r '.labels[].name' 2>/dev/null || true)
|
| jq -r '.labels[].name' 2>/dev/null || true)
|
||||||
|
|
||||||
|
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 echo "$labels" | grep -Fxq "high priority"; then
|
||||||
|
if [ "$INCLUDE_HIGH_PRIORITY" != "true" ]; then
|
||||||
echo " 🛑 Skipping (high priority label)"
|
echo " 🛑 Skipping (high priority label)"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
echo " ⚠️ High priority PR, but include_high_priority is enabled"
|
||||||
|
fi
|
||||||
|
|
||||||
echo " 🚫 Cancelling..."
|
echo " 🚫 Cancelling..."
|
||||||
gh run cancel "$run_id" --repo "$REPO" || echo " ⚠️ Cancellation failed"
|
gh run cancel "$run_id" --repo "$REPO" || echo " ⚠️ Cancellation failed"
|
||||||
|
|||||||
Reference in New Issue
Block a user