Last active
October 22, 2024 08:42
-
-
Save roylines/0995a372e18751dffc18f994535e8364 to your computer and use it in GitHub Desktop.
bash Script to disable all githiub workflows in a directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Ensure gh is installed and authenticated | |
if ! command -v gh &> /dev/null; then | |
echo "GitHub CLI (gh) is not installed. Please install it first." | |
exit 1 | |
fi | |
# Function to disable workflows for a repository | |
disable_workflows() { | |
local repo=$1 | |
echo "Disabling workflows for repository: $repo" | |
cd "$repo" || return | |
# Get all workflows | |
workflows=$(gh workflow list --limit 1000 --json id -q '.[].id') | |
# Disable each workflow | |
for workflow_id in $workflows; do | |
echo " Disabling workflow with ID: $workflow_id" | |
gh workflow disable "$workflow_id" | |
done | |
cd - > /dev/null || return | |
} | |
# Main script | |
for dir in */; do | |
if [ -d "$dir/.git" ]; then | |
disable_workflows "$dir" | |
fi | |
done | |
echo "All workflows in all repositories have been disabled." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment