Remove workflows older than xxx

Hi,

my old github action workflows (more than 600 atm) are still referencing commits that are not referenced by any branch and should normally be unreachable and thus deleted. Maybe the workflow implementation is using underlying branches.

Your ways of managing data storage is none of my business but it actually causes me some pain since the jira integration shows all the commits containing reference to the ticket … even from unreachable commits that have triggered workflows, have been changed and are no longer relevant.

So, as many of us have done before me, I’m begging you to implement an API to remove old executed workflows so we can clean them up like developers do : not manually !

By advance, I thank you for this and for the action workflows that otherwise is perfect for my usage !

Pierre

2 Likes

You can find the documentation for the API to delete a workflow run on the GitHub Docs https://docs.github.com/en/rest/reference/actions#delete-a-workflow-run.

Hi @pierre-gautier,

You can complete this with two apis:

Get all the workflow runs for your repository with this API, add parameters to filter:

curl -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/{org}/{repo}/actions/runs?per_page=100&page=5"  # list page5, per-page 100

parse the workflow run id which timestamp is older than XXX(eg: use jq command).

Create a loop, use the workflow run ids for deletion workflow runs API:
https://docs.github.com/en/rest/reference/actions#delete-a-workflow-run

Thanks

Thanks a lot !

I did some researches before posting but all I could find was this blog entry and did not think to check for the API doc, my bad.

Since others could follow the same path, maybe adding something in this blog entry would be a good idea.

Last but not least, it seems to me that most of github actions users will need an action like purge artifacts to clean runs one day or another. Something even better integrated like configuration would be even greater.

Have a good day