Skip to content

A PowerShell tool to efficiently clean up GitHub Actions workflow history

License

Notifications You must be signed in to change notification settings

mavieiradev/github-actions-cleanup-tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

GitHub Actions History Cleaner

Advanced PowerShell utility for efficiently managing and cleaning up GitHub Actions workflow run history.

Features

  • Selective workflow cleanup based on age
  • Status-based filtering (completed, in_progress, queued, etc.)
  • Simulation mode (WhatIf) to test before execution
  • Safety confirmation prompts
  • Dependency and authentication verification
  • Color-coded progress feedback
  • Support for advanced parameters
  • Limit number of workflows to process

Requirements

  • PowerShell 5.1 or higher
  • GitHub CLI (gh) installed
  • GitHub CLI authentication

Installation

  1. Install GitHub CLI from https://cli.github.com/
  2. Authenticate with GitHub CLI:
    gh auth login
  3. Clone this repository or download the Clean-GitHubActionHistory.ps1 script

Usage

Basic Syntax

.\Clean-GitHubActionHistory.ps1 -Organization "your-username" -Repository "your-repository"

Advanced Parameters

  • -Organization: GitHub organization or username (required)
  • -Repository: Repository name (required)
  • -RetentionDays: Number of days of workflow runs to retain (default: 7)
  • -Status: Filter by workflow status (completed, in_progress, queued, etc.)
  • -Silent: Run without confirmation prompts
  • -WhatIf: Simulate the operation without making changes
  • -MaxItems: Maximum number of workflow runs to process

Examples

  1. Clean all workflows older than 7 days:

    .\Clean-GitHubActionHistory.ps1 -Organization "your-username" -Repository "your-repository"
  2. Keep workflows from the last 30 days:

    .\Clean-GitHubActionHistory.ps1 -Organization "your-username" -Repository "your-repository" -RetentionDays 30
  3. Simulate cleanup (no actual deletion):

    .\Clean-GitHubActionHistory.ps1 -Organization "your-username" -Repository "your-repository" -WhatIf
  4. Clean only completed workflows:

    .\Clean-GitHubActionHistory.ps1 -Organization "your-username" -Repository "your-repository" -Status "completed"
  5. Process without confirmation:

    .\Clean-GitHubActionHistory.ps1 -Organization "your-username" -Repository "your-repository" -Silent
  6. Limit to processing only 100 workflows:

    .\Clean-GitHubActionHistory.ps1 -Organization "your-username" -Repository "your-repository" -MaxItems 100

Security

  • The script requests confirmation before deleting workflows (unless -Silent is used)
  • Verifies GitHub authentication before execution
  • Allows simulation before making actual changes

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

License

MIT License - see the LICENSE file for details.

Releases

No releases published

Packages

No packages published