Merge pull request #1577 from PR0M3TH3AN/add-cancel-ci-script-2946319545185947726

Add script to cancel all CI runs
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-01-23 08:46:20 -05:00
commit 70305b717a
1 file changed
+31
+31
View File
@@ -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."