Skip to content

gabor-kovac/RunCleaner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RunCleaner

Automatically cleans out workflow runs from repositories

This application is written in C# using .NET 8 SDK

Release is a standalone binary, thus .NET runtime is not needed

Supports Linux x64 and Windows x64

Prepare

  1. Download latest release for your platform
  2. Extract release ZIP archive
  3. Run using command line

Usage

This application has no GUI. You will need to use a command-line shell to launch it.

Linux

Invoke with, in a terminal emulator:

  1. Set environment variables

    GITHUB_OWNER=<username>
  2. Run the application

    ./RunCleaner
  3. Optionally do it all inline:

    GITHUB_TOKEN=<token> GITHUB_OWNER=<username> ./RunCleaner

Windows:

  1. Set environment variables

    Using PowerShell:

    $env:GITHUB_OWNER='<username>';

    Using Command Prompt:

    set GITHUB_OWNER=<username>

    Using Git Bash:

    GITHUB_OWNER=<username>
    
  2. Run the application

    PowerShell or Command Prompt:

    .\RunCleaner.exe

    Git Bash:

    ./RunCleaner.exe

Environment variables:

You must provide the mandatory variables

Mandatory:

  • GITHUB_TOKEN - Github PAT, must have repo scope
  • GITHUB_OWNER - Owner of the repositories (github.repository_owner)

Optional:

  • EXCLUDE_PROJECTS - Array of projects you wish to exclude in escaped JSON format
  • CLEAN_OLDER_THAN - Runs that are older than the number of days declared here will get cleaned, defaults to 7

Building

Requirement: .NET 8 SDK

Build with inside the Source directory:

dotnet build

Examples

Clean every runs from repositories that are older than 7 days:

GITHUB_TOKEN=<token> GITHUB_OWNER=<username> ./RunCleaner

Increase maximum workflow run age to 10 days:

CLEAN_OLDER_THAN=10 GITHUB_TOKEN=<token> GITHUB_OWNER=<username> ./RunCleaner

Exclude repositories owner/repo1 and owner/repo2 from cleaning:

EXCLUDE_PROJECTS=[\"owner/repo1\", \"owner/repo2\"] GITHUB_TOKEN=<token> GITHUB_OWNER=<username> ./RunCleaner

License

The scripts and documentation in this project are released under the MIT License.

Credits

LinkHeader.cs - Extension of pimbrouwers's