Delete All GitHub Actions Workflow Runs Using GitHub CLI

June 26, 2026 #github #git

TLDR: Here's the one-liner if you're here to just copy it.

$ gh run list --all --limit 40 --json databaseId | jq '.[].databaseId' | xargs -n1 gh run delete

Make sure to change the limit 40 to whatever number of actions you have.


If you've ever accumulated hundreds (or thousands) of GitHub Actions workflow runs, you've probably wondered how to clean them all up.

To my knowledge, GitHub's web interface provides no interface for this purpose. Unfortunately, there isn't also an obvious builtin GitHub CLI command, like gh run delete --all, that deletes every workflow run in a repository. At best, the gh run delete <run-id> only deletes one workflow run as this command only accepts one argument (or none for an interactive selection before deletion).

If we could find a way to get a list of all runs, we then could wind up a for loop or pipe it to xargs to have them deleted programmatically. For that, the following command

$ gh run list

lists workflow runs in your repository. By default, it only returns 20 workflow runs. We can pass an extra --limit <int> flag to tell it list more. You can check how many workflow runs exist by visiting the Actions tab of your GitHub repository in your browser. Additionally, we have pass --all (or -a) to include disabled workflows.

$ gh run list --all --limit 100

Now, we need to extract the id's from the output, but the output format is in a human-readable/friendly way. In other words, there's no fixed format so that we could parse it with awk, for instance. Luckily, there's a --json flag that you can use to request only the fields/columns you need. To see the list of correct field names, run

gh run list --json

it will show use the various column names. Among them exists the databaseId, which is what we want. Issuing the following gives us a JSON output: a list of objects with only databaseId as key.

$ gh run list --json databaseId
[
  {
    "databaseId": 1234567890
  },
  {
    "databaseId": 1234567891
  }
  ...
]

Simply add more --json <field> pairs to get more columns of data.

Now we need to turn that JSON into a plain list of IDs. The easiest tool to pipe the JSON output into jq. `.` refers to the root JSON value; `[]` iterates over every element in the array; and `.databaseId` selects the `databaseId` property from each object.

$ gh run list --json databaseId | jq '.[].databaseId'
1234567890
1234567891
1234567892
...

Finally, we can go ahead and pipe the ids to xargs to get deleted one-by-one. The `-n1` option tells `xargs` to invoke `gh run delete` once for each input line.

$ gh run list --json databaseId | jq '.[].databaseId' | xargs -n1 gh run delete
✓ Request to delete workflow run submitted.
✓ Request to delete workflow run submitted.
✓ Request to delete workflow run submitted.
...

This is yet another example of how powerful Unix philosophy can be.

X86-64 Assembly on ARM64 Mac