Skip to content

Instantly share code, notes, and snippets.

@retyui
Last active August 10, 2023 16:17
Show Gist options
  • Save retyui/ab8a171b7489d9f83880a9fcb63f58af to your computer and use it in GitHub Desktop.
Save retyui/ab8a171b7489d9f83880a9fcb63f58af to your computer and use it in GitHub Desktop.
Simple way to remove all workflow runs in GitHub Actions:

Simple way to remove all workflow runs in Github Actions:

export user=NameOrOrgName
export repo=RepoName


gh api repos/$user/$repo/actions/runs --paginate -q '.workflow_runs[] | "\(.id)"'  | xargs -n1 -I % gh api repos/$user/$repo/actions/runs/% -X DELETE


gh api "repos/$user/$repo/actions/runs?created=*..2022-07-16" --paginate -q '.workflow_runs[] | "\(.id)"'  | xargs -n1 -I % gh api repos/$user/$repo/actions/runs/% -X DELETE

gh api repos/$user/$repo/actions/runs?created=2022-06-15..2022-07-16

gh api "repos/$user/$repo/actions/runs?workflow_id=21456768"


  {
      "id": 2677488357,
      "name": "aaaa",
      "node_id": "WFR_kwLOFhRH7c6flzrl",
      "head_branch": "name",
      "head_sha": "e90657391639ee0d1f645ca83bb7ef1e1218ed32",
      "path": ".github/workflows/name.yml",
      "run_number": 4759,
      "event": "pull_request",
      "status": "completed",
      "conclusion": "success",
      "workflow_id": 21456768,
      "check_suite_id": 7375336252,
      "check_suite_node_id": "CS_kwDOFhRH7c8AAAABt5qzPA",
      "url": "https://api.github.com/repos/name/repo/actions/runs/2677488357",
      "html_url": "https://github.com/name/repo/actions/runs/2677488357",
      "pull_requests": [],
      "created_at": "2022-07-15T14:35:25Z",
      "updated_at": "2022-07-15T14:49:51Z",



gh api "repos/$user/$repo/actions/runs?created=*..2022-07-16" --paginate -q '.workflow_runs[] | "\(.id)"'  | xargs -n1 -I % gh api repos/$user/$repo/actions/runs/% -X DELETE

gh api "repos/$user/$repo/actions/runs?created=*..2022-07-16" --paginate -q '.workflow_runs[] | "\(.id)"'  > ids.txt
cat ids.txt | xargs -n1 -I % gh api repos/$user/$repo/actions/runs/% -X DELETE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment