Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions disable-all-workflows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ set -euo pipefail
# Disable pager for gh CLI to prevent interactive prompts
export GH_PAGER=""

if [[ $# -ne 2 ]]; then
echo "Usage: $0 <owner> <repo>"
if [[ ${#} -ne 2 ]]; then
echo "Usage: ${0} <owner> <repo>"
exit 1
fi

OWNER=$1
REPO=$2
OWNER=${1}
REPO=${2}

# ensure GH CLI is logged in
if ! gh auth status > /dev/null 2>&1; then
Expand All @@ -25,22 +25,22 @@ fi
# get IDs of only active workflows
active_ids=$(gh api \
--method GET \
/repos/"$OWNER"/"$REPO"/actions/workflows \
/repos/"${OWNER}"/"${REPO}"/actions/workflows \
--paginate \
--jq '.workflows[] | select(.state=="active") | .id')

if [[ -z "$active_ids" ]]; then
echo "No active workflows to disable in $OWNER/$REPO."
if [[ -z "${active_ids}" ]]; then
echo "No active workflows to disable in ${OWNER}/${REPO}."
exit 0
fi

for id in $active_ids; do
for id in ${active_ids}; do
echo -n "Disabling workflow ID ${id}… "
gh api \
--method PUT \
/repos/"$OWNER"/"$REPO"/actions/workflows/"$id"/disable \
/repos/"${OWNER}"/"${REPO}"/actions/workflows/"${id}"/disable \
&& echo "OK" \
|| echo "FAILED"
done

echo "✅ Done—disabled all active workflows in $OWNER/$REPO."
echo "✅ Done—disabled all active workflows in ${OWNER}/${REPO}."