Skip to content

Disabling all GitHub Actions

Alexander Popel edited this page Oct 18, 2023 · 1 revision

This script will disable all GitHub Actions of the provided repositories:

#!/bin/bash
set -u
IFS=$'\n'

token=${GITHUB_TOKEN?Not found}

gh() { curl -X "$1" --fail-with-body -sLH "Authorization: Bearer $token" "https://api.github.com$2"; }

# To get the list you can do:
#   gh GET /orgs/postindustria-tech/repos | jq -r .[].name
repos=(
	pipeline-python
	tools
	documentation
	device-detection-python
	pipeline-node
	device-detection-cxx
	device-detection-data
	common-cxx
	device-detection-node
	location-python
	location-node
	pipeline-php-core
	pipeline-php-engines
	pipeline-php-cloudrequestengine
	device-detection-php
	device-detection-php-onpremise
	location-php
)

for repo in "${repos[@]}"; do
	echo "Getting the list of $repo workflows..."
	workflows=$(gh GET "/repos/postindustria-tech/$repo/actions/workflows" | jq -r '.workflows[] | select(.state=="active").id')
	for workflow in $workflows; do
		echo "Disabling workflow id: $workflow"
		gh PUT "/repos/postindustria-tech/$repo/actions/workflows/$workflow/disable"
	done
done
Clone this wiki locally