mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-04 03:42:26 +00:00
Added `scripts/cancel-all-ci-runs.sh` to allow users to cancel all in-progress and queued GitHub Actions runs. This script requires the GitHub CLI (`gh`) to be installed and authenticated. It uses batch cancellation (`xargs`) and an increased limit (1000) for efficiency and coverage.
32 lines
803 B
Bash
Executable File
32 lines
803 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Check if gh is installed
|
|
if ! command -v gh &> /dev/null
|
|
then
|
|
echo "GitHub CLI (gh) could not be found. Please install it and authenticate (gh auth login) to use this script."
|
|
exit 1
|
|
fi
|
|
|
|
echo "Fetching active runs..."
|
|
|
|
# Function to cancel runs by status
|
|
cancel_runs() {
|
|
local status=$1
|
|
echo "Cancelling $status runs..."
|
|
# Use --limit 1000 to capture up to 1000 runs (default is 30)
|
|
ids=$(gh run list --status "$status" --limit 1000 --json databaseId -q '.[].databaseId')
|
|
|
|
if [ -z "$ids" ]; then
|
|
echo "No $status runs found."
|
|
else
|
|
# Pass IDs to xargs to batch cancel commands
|
|
# gh run cancel accepts multiple arguments
|
|
echo "$ids" | xargs gh run cancel
|
|
fi
|
|
}
|
|
|
|
cancel_runs "in_progress"
|
|
cancel_runs "queued"
|
|
|
|
echo "Done."
|