{"id":16420448,"url":"https://github.com/grindsa/gh_workflow_runs_clean","last_synced_at":"2026-05-15T11:03:08.413Z","repository":{"id":62226729,"uuid":"376880196","full_name":"grindsa/gh_workflow_runs_clean","owner":"grindsa","description":"Script to cleanup github worflow runs and artifacts","archived":false,"fork":false,"pushed_at":"2025-05-20T10:33:47.000Z","size":46,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-12T07:05:29.354Z","etag":null,"topics":["github-actions","worflows","workflow-runs"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grindsa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-06-14T15:59:12.000Z","updated_at":"2025-05-20T10:33:50.000Z","dependencies_parsed_at":"2024-01-16T11:31:58.667Z","dependency_job_id":"e90009af-dbad-4332-8385-624abe83a21f","html_url":"https://github.com/grindsa/gh_workflow_runs_clean","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/grindsa/gh_workflow_runs_clean","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grindsa%2Fgh_workflow_runs_clean","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grindsa%2Fgh_workflow_runs_clean/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grindsa%2Fgh_workflow_runs_clean/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grindsa%2Fgh_workflow_runs_clean/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grindsa","download_url":"https://codeload.github.com/grindsa/gh_workflow_runs_clean/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grindsa%2Fgh_workflow_runs_clean/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285051560,"owners_count":27106642,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-18T02:00:05.759Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github-actions","worflows","workflow-runs"],"created_at":"2024-10-11T07:28:03.167Z","updated_at":"2026-05-15T11:03:08.407Z","avatar_url":"https://github.com/grindsa.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- markdownlint-disable  MD013 --\u003e\n# gh_workflow_runs_delete.py\n\n`gh_workflow_runs_delete.py` is a small python script helping you to \"mass-delete\" Github Actions workflow runs as such a feature isn't available in the webbased Actions UI.\n\nIt uses the WorkFlow Runs API allowing `delete` operations by using the `/repos/{owner}/{repo}/actions/runs` endpoint.\n\nBy default the script scans a repository to get a list of branches and deletes all workflow runs except the ones belonging to the latest commit per branch. The list of branches as well as the amount of commits to be kept can be adjusted.\n\n## Pre-requisites\n\nYou need a personal access token with the following permissions:\n\n- repo\n- workflow\n- read:org\n\n## Installation\n\n- download and unpack the archive\n- install dependencies\n\n```bash\n\u003e pip install -r requirements.txt\n```\n\n## Usage\n\n```bash\npython3 ./gh_workflow_runs_delete.py -r {owner}/{repo} -t {TOKEN} -u {github_user}\n```\n\nBelow the list of command line options\n\n```bash\npy gh_actions_clean\u003e py .\\gh_workflow_runs_delete.py -h\n\nusage: gh_workflow_runs_delete.py [-h] [-d] [-r REPONAME] [-u USERNAME] [-t TOKEN] [-c COMMITS]\n                                  [--branchlist BRANCHLIST]\n\ngh_workflow_runs_delete.py - delete github action logs and artifacts\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -d, --debug           debug mode\n  -r REPONAME, --reponame REPONAME\n                        repositoryname\n  -u USERNAME, --username USERNAME\n                        username\n  -t TOKEN, --token TOKEN\n                        token\n  -c COMMITS, --commits COMMITS\n                        number of commits to keep\n  --branchlist BRANCHLIST\n                        list of branches\n```\n\n## Usage as part of a Github workflow\n\nI created an [example workflow](https://github.com/grindsa/gh_workflow_runs_clean/blob/main/.github/workflows/gha_clean.yml) which is cleaning up my repositories once a week.\n\n```YAML\n\n# workflow to clean github workflow runs for my repositories\nname: Github WF Runs Clean\non:\n  push:\n  schedule:\n    # * is a special character in YAML so you have to quote this string\n    - cron:  '0 2 * * 6'\n\njobs:\n  gha_clean:\n    runs-on: ubuntu-latest\n    name: Github WF Runs Clean\n    steps:\n    - uses: actions/checkout@v2\n    - name: Install dependencies\n      run: |\n        python -m pip install --upgrade pip\n        pip install pytest\n        if [ -f requirements.txt ]; then pip install -r requirements.txt; fi\n    - name: check self\n      run: |\n        python3 ./gh_workflow_runs_delete.py -d  -r grindsa/github_actions_clean -t ${{ secrets.GH_TOKEN }} -u ${{ secrets.GH_USER }}  -c 1\n    - name: check a2c\n      run: |\n        python3 ./gh_workflow_runs_delete.py -d  -r grindsa/acme2certifier -t ${{ secrets.GH_TOKEN }} -u ${{ secrets.GH_USER }}  -c 1\n    - name: check est_proxy\n      run: |\n        python3 ./gh_workflow_runs_delete.py -d  -r grindsa/est_proxy -t ${{ secrets.GH_TOKEN }} -u ${{ secrets.GH_USER }}  -c 1\n    - name: check dkb-robo\n      run: |\n        python3 ./gh_workflow_runs_delete.py -d  -r grindsa/dkb-robo -t ${{ secrets.GH_TOKEN }} -u ${{ secrets.GH_USER }}  -c 1\n```\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](https://github.com/grindsa/gh_workflow_runs_clean/blob/main/CONTRIBUTING.md) for details on my code of conduct, and the process for submitting pull requests.\nPlease note that I have a life besides programming. Thus, expect a delay in answering.\n\n## Versioning\n\nI use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/grindsa/gh_workflow_runs_clean/tags).\n\n## License\n\nThis project is licensed under the GPLv3 - see the [LICENSE.md](https://github.com/grindsa/gh_workflow_runs_clean/blob/main/LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrindsa%2Fgh_workflow_runs_clean","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrindsa%2Fgh_workflow_runs_clean","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrindsa%2Fgh_workflow_runs_clean/lists"}