Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Script to cleanup github worflow runs and artifacts

License

NotificationsYou must be signed in to change notification settings

grindsa/gh_workflow_runs_clean

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.

Pre-requisites

You need a personal access token with the following permissions:

  • repo
  • workflow
  • read:org

Installation

  • download and unpack the archive
  • install dependencies
> pip install -r requirements.txt

Usage

python3 ./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

Usage as part of a Github workflow

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

Contributing

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.

Versioning

I useSemVer for versioning. For the versions available, see thetags on this repository.

License

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

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp