Releases: Siddhant-K-code/cleanup-gitpod-environments
Releases · Siddhant-K-code/cleanup-gitpod-environments
v1.1
What's New
- Only deletes remote runner environments
- Enhanced rate limiting protection with exponential backoff
- Detailed debug logging for better troubleshooting
- Improved error handling with retries
- Updated documentation
Gitpod Environment Cleanup Action - v1.0.0
Automatically clean up stale Gitpod environments that haven't been started for a specified number of days and have no pending changes. This action helps maintain a clean workspace and manage resource usage in your Gitpod Flex organization.
Important
GITPOD_TOKEN
: Required. Learn more about how to create a Gitpod Personal Access Token in Gitpod Flex.
Core Features 🚀
- Automated cleanup of stale Gitpod environments
- Smart detection using
lastStartedAt
timestamp - Safe cleanup criteria to prevent data loss
- Pagination support for large organizations
- Configurable cleanup thresholds
- Detailed operation logging
- Optional summary reports
- Weekly scheduled cleanup support
Enhanced Summary Reports 🎯
The action now provides comprehensive summary reports that help track and analyze environment cleanup operations. Each report includes:
- Total environments cleaned and their statistics
- Average inactivity duration
- Detailed environment information
- Project associations and creator details
- Clear timeline of environment usage
- Age analysis of deleted environments
This enhanced reporting helps teams:
- Track cleanup patterns and effectiveness
- Monitor environment lifecycle
- Identify potential resource waste
- Make informed decisions about cleanup policies
Usage 📝
Basic Example
name: Cleanup Gitpod Environments
on:
schedule:
- cron: '0 14 * * 6' # Runs at 2:00 PM UTC every Saturday
workflow_dispatch: # Allows manual triggering
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Cleanup Stale Environments
uses: siddhant-k-code/cleanup-gitpod-environments@v1
with:
GITPOD_TOKEN: ${{ secrets.GITPOD_TOKEN }}
ORGANIZATION_ID: ${{ secrets.GITPOD_ORGANIZATION_ID }}
Advanced Example with All Options
name: Cleanup Gitpod Environments
on:
schedule:
- cron: '0 14 * * 6'
workflow_dispatch:
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Cleanup Stale Environments
uses: siddhant-k-code/cleanup-gitpod-environments@v1
with:
GITPOD_TOKEN: ${{ secrets.GITPOD_TOKEN }}
ORGANIZATION_ID: ${{ secrets.GITPOD_ORGANIZATION_ID }}
OLDER_THAN_DAYS: '15' # Custom age threshold
PRINT_SUMMARY: 'true' # Enable detailed summary
Inputs ⚙️
Input | Required | Default | Description |
---|---|---|---|
GITPOD_TOKEN |
Yes | - | Gitpod Personal Access Token |
ORGANIZATION_ID |
Yes | - | Gitpod Flex organization ID |
OLDER_THAN_DAYS |
No | 10 | Delete environments older than X days |
PRINT_SUMMARY |
No | false | Generate detailed summary report |
Outputs 📊
Output | Description |
---|---|
success |
'true' if cleanup completed successfully |
deleted_count |
Number of environments deleted |
avg_days_inactive |
Average days of inactivity |
Summary Report Example 📑
# Environment Cleanup Summary
| Metric | Value |
| -------------------------- | ----------- |
| Total Environments Cleaned | 5 |
| Average Days Inactive | 15.3 days |
| Oldest Last Start | 25 days ago |
| Newest Last Start | 10 days ago |
## Deleted Environments
| Environment ID | Project | Last Activity | Created | Creator | Days Inactive |
| -------------- | ---------------------------------- | ------------- | ---------- | -------- | ------------- |
| 01924aff-... | github.com/siddhant-k-code/website | 2023-11-01 | 2023-10-15 | user-123 | 15 days |
| 01924bff-... | github.com/siddhant-k-code/docs | 2023-10-25 | 2023-10-01 | user-456 | 22 days |
| 01924cff-... | github.com/siddhant-k-code/example | 2023-10-20 | 2023-09-15 | user-789 | 18 days |
Cleanup Criteria 🔍
An environment is deleted only if ALL conditions are met:
- Not started for X days (configurable)
- Currently in STOPPED phase
- No uncommitted changes
- No unpushed commits
Security Measures 🔒
- Only affects completely stopped environments
- Preserves environments with pending changes
- Requires explicit organization ID
- Detailed logging of all operations
- Summary reports for audit trails
Required Setup 🛠️
- Generate a Gitpod Personal Access Token
- Get your Gitpod Flex organization ID
- Add both as GitHub secrets
- Configure cleanup schedule
- Optional: Customize cleanup thresholds
Acknowledgments
This action is maintained by @Siddhant-K-code and is not an official Gitpod product.