mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-02 19:02:28 +00:00
update
This commit is contained in:
1 parent
725e3eb28b
commit
d937f04ba3
1 file changed
+16
-4
@@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# Check if gh is installed
|
||||
if ! command -v gh &> /dev/null
|
||||
@@ -7,6 +8,18 @@ then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Allow override with REPO=owner/repo
|
||||
REPO="${REPO:-}"
|
||||
if [ -z "$REPO" ]; then
|
||||
# try to discover the repo from the current git folder
|
||||
REPO="$(gh repo view --json nameWithOwner -q .nameWithOwner 2>/dev/null || true)"
|
||||
if [ -z "$REPO" ]; then
|
||||
echo "Unable to determine repository. Either run this inside the repo or set REPO=owner/repo"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Repo: $REPO"
|
||||
echo "Fetching active runs..."
|
||||
|
||||
# Function to cancel runs by status
|
||||
@@ -14,14 +27,13 @@ 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')
|
||||
ids=$(gh run list --repo "$REPO" --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
|
||||
# Call gh run cancel once per id (some gh versions accept only one id per call)
|
||||
printf '%s\n' "$ids" | xargs -r -n1 -I{} gh run cancel --repo "$REPO" {}
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user