Advanced PowerShell utility for efficiently managing and cleaning up GitHub Actions workflow run history.
- 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
- PowerShell 5.1 or higher
- GitHub CLI (gh) installed
- GitHub CLI authentication
- Install GitHub CLI from https://cli.github.com/
- Authenticate with GitHub CLI:
gh auth login
- Clone this repository or download the
Clean-GitHubActionHistory.ps1
script
.\Clean-GitHubActionHistory.ps1 -Organization "your-username" -Repository "your-repository"
-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
-
Clean all workflows older than 7 days:
.\Clean-GitHubActionHistory.ps1 -Organization "your-username" -Repository "your-repository"
-
Keep workflows from the last 30 days:
.\Clean-GitHubActionHistory.ps1 -Organization "your-username" -Repository "your-repository" -RetentionDays 30
-
Simulate cleanup (no actual deletion):
.\Clean-GitHubActionHistory.ps1 -Organization "your-username" -Repository "your-repository" -WhatIf
-
Clean only completed workflows:
.\Clean-GitHubActionHistory.ps1 -Organization "your-username" -Repository "your-repository" -Status "completed"
-
Process without confirmation:
.\Clean-GitHubActionHistory.ps1 -Organization "your-username" -Repository "your-repository" -Silent
-
Limit to processing only 100 workflows:
.\Clean-GitHubActionHistory.ps1 -Organization "your-username" -Repository "your-repository" -MaxItems 100
- The script requests confirmation before deleting workflows (unless -Silent is used)
- Verifies GitHub authentication before execution
- Allows simulation before making actual changes
Contributions are welcome! Feel free to open issues or submit pull requests.
MIT License - see the LICENSE file for details.