Skip to content

Instantly share code, notes, and snippets.

@tomarv2
Last active March 5, 2021 05:24
Show Gist options
  • Save tomarv2/884632fed8f541d28e587d665e2eb180 to your computer and use it in GitHub Desktop.
Save tomarv2/884632fed8f541d28e587d665e2eb180 to your computer and use it in GitHub Desktop.
GitHub Action workflow runs cleanup
# NOTE: Ensure you are logged into the right github account
# https://cli.github.com/manual/gh_auth_login
OWNER=tomarv2
REPO=demo
# list all workflows
gh api -X GET /repos/$OWNER/$REPO/actions/workflows | jq '.workflows[] | .name,.id'
# get the workflow id you want to clear
WORKFLOW_ID=123456
# list all runs for the workflow
gh api -X GET /repos/$OWNER/$REPO/actions/workflows/$WORKFLOW_ID/runs | jq '.workflow_runs[] | .id'
# delete all runs for the workflow
gh api -X GET /repos/$OWNER/$REPO/actions/workflows/$WORKFLOW_ID/runs | jq '.workflow_runs[] | .id' | xargs -I{} gh api -X DELETE /repos/$OWNER/$REPO/actions/runs/{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment