Last active
March 5, 2021 05:24
-
-
Save tomarv2/884632fed8f541d28e587d665e2eb180 to your computer and use it in GitHub Desktop.
GitHub Action workflow runs cleanup
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
| # 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