Skip to content

Instantly share code, notes, and snippets.

@bradymholt
Created January 12, 2022 18:18
Show Gist options
  • Save bradymholt/c8cb8b3a8a42dd711271739c2289a618 to your computer and use it in GitHub Desktop.
Save bradymholt/c8cb8b3a8a42dd711271739c2289a618 to your computer and use it in GitHub Desktop.
Delete all disabled GitHub Action workflow runs
# Source :https://stackoverflow.com/a/67000032/626911
org=<your org>
repo=<your repo>
# Get workflow IDs with status "disabled_manually"
workflow_ids=($(gh api repos/$org/$repo/actions/workflows | 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