Last active
January 26, 2023 11:04
-
-
Save codeeshop-oc/59ecd29ef0143d6c703037b20b3f92f9 to your computer and use it in GitHub Desktop.
Delete All Workflows Using Shell Script
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
read -p "Enter your [Branch/repo]: " branch_repo | |
branch_repo=${branchrepo:-"DEFAULT_REPO_NAME"} | |
# To Get workflow IDs with status "disabled_manually" add | contains("disabled_manually") | |
workflow_ids=($(gh api repos/$branch_repo/actions/workflows | jq '.workflows[] | select(.["state"]) | .id')) | |
for workflow_id in "${workflow_ids[@]}" | |
do | |
echo "Listing runs for the workflow ID $workflow_id" | |
run_ids=( $(gh api repos/$branch_repo/actions/workflows/$workflow_id/runs --paginate | jq '.workflow_runs[].id') ) | |
for run_id in "${run_ids[@]}" | |
do | |
echo "Deleting Run ID $run_id" | |
gh api repos/$branch_repo/actions/runs/$run_id -X DELETE >/dev/null | |
done | |
done | |
# Source - https://stackoverflow.com/questions/57927115/delete-a-workflow-from-github-actions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment