Last active
March 22, 2025 07:51
-
-
Save finesse-fingers/31b35e54227913713f96fd5524c2d2ab to your computer and use it in GitHub Desktop.
Delete a disabled github actions workflow
This file contains hidden or 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
# ref: https://stackoverflow.com/a/67000032/6648687 | |
org=<org-name> | |
repo=<repo-name> | |
# Get workflow IDs with status "disabled_manually" | |
workflow_ids=($(gh api repos/$org/$repo/actions/workflows --paginate | jq '.workflows[] | select(.["state"] | contains("disabled_manually")) | .id')) | |
for workflow_id in "${workflow_ids[@]}" | |
do | |
echo "Listing runs for the workflow ID $workflow_id" | |
run_ids=( $(gh api repos/$org/$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/$org/$repo/actions/runs/$run_id -X DELETE >/dev/null | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment