Skip to content

Instantly share code, notes, and snippets.

@andyhite
Created May 19, 2022 14:31
Show Gist options
  • Save andyhite/0d1a378a880686765e5548b62e80a425 to your computer and use it in GitHub Desktop.
Save andyhite/0d1a378a880686765e5548b62e80a425 to your computer and use it in GitHub Desktop.
Delete all runs of a specific GitHub Workflow with one command
export GH_PAGER=cat # this is important to keep gh from using less as a pager
export GH_REPO="<org-name>/<repo-name>" # for instance, shipengine/shipengine-elements
export GH_WORKFLOW_FILENAME="<workflow-filename>" # for instance, "lint-and-test.yml"
gh api repos/$GH_REPO/actions/workflows/$GH_WORKFLOW_FILENAME/runs --paginate --jq '.workflow_runs[] | .id' | \
xargs -n 1 -I % gh api repos/$GH_REPO/actions/runs/% -X DELETE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment