- Notifications
You must be signed in to change notification settings - Fork0
Script to cleanup github worflow runs and artifacts
License
grindsa/gh_workflow_runs_clean
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
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.
It uses the WorkFlow Runs API allowingdelete operations by using the/repos/{owner}/{repo}/actions/runs endpoint.
By 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.
You need a personal access token with the following permissions:
- repo
- workflow
- read:org
- download and unpack the archive
- install dependencies
> pip install -r requirements.txtpython3 ./gh_workflow_runs_delete.py -r {owner}/{repo} -t {TOKEN} -u {github_user}Below the list of command line options
py gh_actions_clean> py .\gh_workflow_runs_delete.py -husage: gh_workflow_runs_delete.py [-h] [-d] [-r REPONAME] [-u USERNAME] [-t TOKEN] [-c COMMITS] [--branchlist BRANCHLIST]gh_workflow_runs_delete.py - delete github action logs and artifactsoptional arguments: -h, --help show thishelp message andexit -d, --debug debug mode -r REPONAME, --reponame REPONAME repositoryname -u USERNAME, --username USERNAME username -t TOKEN, --token TOKEN token -c COMMITS, --commits COMMITS number of commits to keep --branchlist BRANCHLIST list of branches
I created anexample workflow which is cleaning up my repositories once a week.
# workflow to clean github workflow runs for my repositoriesname:Github WF Runs Cleanon:push:schedule:# * is a special character in YAML so you have to quote this string -cron:'0 2 * * 6'jobs:gha_clean:runs-on:ubuntu-latestname:Github WF Runs Cleansteps: -uses:actions/checkout@v2 -name:Install dependenciesrun:| python -m pip install --upgrade pip pip install pytest if [ -f requirements.txt ]; then pip install -r requirements.txt; fi -name:check selfrun:| python3 ./gh_workflow_runs_delete.py -d -r grindsa/github_actions_clean -t ${{ secrets.GH_TOKEN }} -u ${{ secrets.GH_USER }} -c 1 -name:check a2crun:| python3 ./gh_workflow_runs_delete.py -d -r grindsa/acme2certifier -t ${{ secrets.GH_TOKEN }} -u ${{ secrets.GH_USER }} -c 1 -name:check est_proxyrun:| python3 ./gh_workflow_runs_delete.py -d -r grindsa/est_proxy -t ${{ secrets.GH_TOKEN }} -u ${{ secrets.GH_USER }} -c 1 -name:check dkb-roborun:| python3 ./gh_workflow_runs_delete.py -d -r grindsa/dkb-robo -t ${{ secrets.GH_TOKEN }} -u ${{ secrets.GH_USER }} -c 1
Please readCONTRIBUTING.md for details on my code of conduct, and the process for submitting pull requests.Please note that I have a life besides programming. Thus, expect a delay in answering.
I useSemVer for versioning. For the versions available, see thetags on this repository.
This project is licensed under the GPLv3 - see theLICENSE.md file for details
About
Script to cleanup github worflow runs and artifacts
Topics
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.