From d0c6699cdc53780b2102be53b23c1fb0b721e10f Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 23 Jan 2026 13:36:14 +0000 Subject: [PATCH] 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. --- scripts/cancel-all-ci-runs.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 scripts/cancel-all-ci-runs.sh diff --git a/scripts/cancel-all-ci-runs.sh b/scripts/cancel-all-ci-runs.sh new file mode 100755 index 00000000..187c53f6 --- /dev/null +++ b/scripts/cancel-all-ci-runs.sh @@ -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."