Skip to content

Instantly share code, notes, and snippets.

@MrChocolatine
Last active December 3, 2022 15:30
Show Gist options
  • Save MrChocolatine/3245610495df711b266fc4237a0e1529 to your computer and use it in GitHub Desktop.
Save MrChocolatine/3245610495df711b266fc4237a0e1529 to your computer and use it in GitHub Desktop.
GitHub - How to delete all workflow runs

While GitHub provides the ability to remove old workflow runs (https://github.blog/changelog/2020-07-07-github-actions-ability-to-delete-workflow-runs/), it fails to provide an option to delete all workflow runs for a particular workflow.

Manual deletion can become extremely tedious...

Turns out, this can be achieved using GitHub CLI (https://github.com/cli/cli), read on.

  • Idea initially noticed here: refined-github/refined-github#4838

  • Which brought me here: cli/cli#6449 where this solution in given:

    gh run \
      list --json databaseId  -q '.[].databaseId' -w integration.yml --limit 500 \
      | xargs -IID -P 15 \
        gh api "repos/$(gh repo view --json nameWithOwner -q .nameWithOwner)/actions/runs/ID" \
        -X DELETE
    
@fregante
Copy link

fregante commented Dec 3, 2022

I am @fregante and I approve this message 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment