mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-02 02:42:28 +00:00
Add script to cancel all CI runs
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.
This commit is contained in:
1 parent
2029ba6272
commit
d0c6699cdc
1 file changed
+31
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/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."
|
||||
Reference in new issue
Block a user