Skip to content

Instantly share code, notes, and snippets.

@roylines
Last active October 22, 2024 08:42
Show Gist options
  • Save roylines/0995a372e18751dffc18f994535e8364 to your computer and use it in GitHub Desktop.
Save roylines/0995a372e18751dffc18f994535e8364 to your computer and use it in GitHub Desktop.
bash Script to disable all githiub workflows in a directory
#!/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