{"id":21517105,"url":"https://github.com/siddhant-k-code/cleanup-gitpod-environments","last_synced_at":"2025-04-24T05:48:12.964Z","repository":{"id":261752245,"uuid":"885215374","full_name":"Siddhant-K-code/cleanup-gitpod-environments","owner":"Siddhant-K-code","description":"Find \u0026 Delete stale environments in a Gitpod (Flex) organization","archived":false,"fork":false,"pushed_at":"2025-01-10T13:54:35.000Z","size":24,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-24T05:48:05.715Z","etag":null,"topics":["cleanup-action","cleanup-tool","github-actions","gitpod","gitpod-api","gitpod-flex","stale"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Siddhant-K-code.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-08T07:12:06.000Z","updated_at":"2025-03-28T08:25:31.000Z","dependencies_parsed_at":"2024-11-08T08:50:12.317Z","dependency_job_id":null,"html_url":"https://github.com/Siddhant-K-code/cleanup-gitpod-environments","commit_stats":null,"previous_names":["siddhant-k-code/cleanup-gitpod-environments"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Siddhant-K-code%2Fcleanup-gitpod-environments","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Siddhant-K-code%2Fcleanup-gitpod-environments/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Siddhant-K-code%2Fcleanup-gitpod-environments/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Siddhant-K-code%2Fcleanup-gitpod-environments/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Siddhant-K-code","download_url":"https://codeload.github.com/Siddhant-K-code/cleanup-gitpod-environments/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250573344,"owners_count":21452345,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cleanup-action","cleanup-tool","github-actions","gitpod","gitpod-api","gitpod-flex","stale"],"created_at":"2024-11-24T00:34:17.830Z","updated_at":"2025-04-24T05:48:12.947Z","avatar_url":"https://github.com/Siddhant-K-code.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e [!NOTE]\n\u003e This is for [Gitpod Flex](https://app.gitpod.io), if you are using [Gitpod Classic](https://gitpod.io/workspaces) (PAYG), please refer to the [Gitpod Classic Environment Cleanup Action](https://github.com/marketplace/actions/delete-clean-gitpod-workspaces)\n\n# Gitpod Environment Cleanup Action\n\nAutomatically 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.\n\n\u003e [!IMPORTANT]\n\u003e `GITPOD_TOKEN`: Required. [Learn more](https://www.gitpod.io/docs/flex/integrations/personal-access-token) about how to create a Gitpod Personal Access Token in Gitpod Flex.\n\n\n## Features\n\n- 🧹 Cleans up stale environments automatically\n- ⏰ Configurable inactivity threshold (default: 10 days since last start)\n- ✅ Smart cleanup - only deletes environments that are:\n  - In STOPPED phase\n  - Have no uncommitted changes\n  - Have no unpushed commits\n  - Haven't been started for X days\n- 📄 Optional summary report of deleted environments\n- 🔒 Only deletes environments that are running in remote runners (not local runners)\n- 🔄 Handles pagination for organizations with many environments\n- ⚡ Smart rate limiting with exponential backoff\n- 🔍 Detailed operation logging for better troubleshooting\n\n## Usage\n\n### Basic Usage\n\nCreate a new workflow file (e.g., `.github/workflows/cleanup-gitpod-environments.yml`):\n\n```yaml\nname: Cleanup Gitpod Environments\n\non:\n  schedule:\n    - cron: '0 14 * * 6'  # Runs at 2:00 PM UTC (14:00) every Saturday\n  workflow_dispatch:      # Allows manual triggering\n\njobs:\n  cleanup:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Cleanup Old Environments\n        uses: Siddhant-K-code/cleanup-gitpod-environments@v1.1\n        with:\n          GITPOD_TOKEN: ${{ secrets.GITPOD_TOKEN }}\n          ORGANIZATION_ID: ${{ secrets.GITPOD_ORGANIZATION_ID }}\n```\n\n### Advanced Usage\n\n```yaml\nname: Cleanup Gitpod Environments\n\non:\n  schedule:\n    - cron: '0 14 * * 6'  # Runs at 2:00 PM UTC (14:00) every Saturday\n  workflow_dispatch:      # Allows manual triggering\n\njobs:\n  cleanup:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Cleanup Old Environments\n        uses: Siddhant-K-code/cleanup-gitpod-environments@v1.1\n        with:\n          GITPOD_TOKEN: ${{ secrets.GITPOD_TOKEN }}\n          ORGANIZATION_ID: ${{ secrets.GITPOD_ORGANIZATION_ID }}\n          OLDER_THAN_DAYS: 15\n          PRINT_SUMMARY: true\n```\n\n## Inputs ⚙️\n\n| Input             | Required | Default | Description                           |\n| ----------------- | -------- | ------- | ------------------------------------- |\n| `GITPOD_TOKEN`    | Yes      | -       | Gitpod Personal Access Token          |\n| `ORGANIZATION_ID` | Yes      | -       | Gitpod Flex organization ID           |\n| `OLDER_THAN_DAYS` | No       | 10      | Delete environments older than X days |\n| `PRINT_SUMMARY`   | No       | false   | Generate detailed summary report      |\n\n## Outputs 📊\n\n| Output              | Description                              |\n| ------------------- | ---------------------------------------- |\n| `success`           | 'true' if cleanup completed successfully |\n| `deleted_count`     | Number of environments deleted           |\n| `avg_days_inactive` | Average days of inactivity               |\n\n## Summary Report Example 📑\n\n```markdown\n# Environment Cleanup Summary\n\n| Metric                     | Value       |\n| -------------------------- | ----------- |\n| Total Environments Cleaned | 5           |\n| Average Days Inactive      | 15.3 days   |\n| Oldest Last Start          | 25 days ago |\n| Newest Last Start          | 10 days ago |\n\n## Deleted Environments\n\n| Environment ID | Project                            | Last Activity | Created    | Creator  | Days Inactive |\n| -------------- | ---------------------------------- | ------------- | ---------- | -------- | ------------- |\n| 01924aff-...   | github.com/siddhant-k-code/website | 2023-11-01    | 2023-10-15 | user-123 | 15 days       |\n| 01924bff-...   | github.com/siddhant-k-code/docs    | 2023-10-25    | 2023-10-01 | user-456 | 22 days       |\n| 01924cff-...   | github.com/siddhant-k-code/example | 2023-10-20    | 2023-09-15 | user-789 | 18 days       |\n```\n\n## Prerequisites\n\n1. **Gitpod Personal Access Token**:\n   - Go to [Gitpod User Settings](https://app.gitpod.io/settings/personal-access-tokens)\n   - Create a new token with necessary permissions\n   - Add it as a GitHub secret named `GITPOD_TOKEN`\n\n2. **Organization ID**:\n   - Get your organization ID from Gitpod Flex dashboard\n   - Add it as a GitHub secret named `GITPOD_ORGANIZATION_ID`\n\n## Cleanup Criteria 🔍\n\nAn environment is deleted only if ALL conditions are met:\n- It is a environment running in Remote runner.\n- Currently in STOPPED or UNSPECIFIED phase\n- Not started for X days (configurable)\n- No uncommitted changes\n- No unpushed commits\n\n## Security Considerations\n\n- Always store your Gitpod token and organization ID as GitHub secrets\n- Review the environments being deleted in the action logs\n- Consider starting with a higher `OLDER_THAN_DAYS` value and gradually decreasing it\n\n## Support\n\nFor issues and feature requests, please create an issue in this repository.\n\n## Acknowledgments\n\nThis action is maintained by [@Siddhant-K-code](https://github.com/Siddhant-K-code) and is not an official Gitpod product.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiddhant-k-code%2Fcleanup-gitpod-environments","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiddhant-k-code%2Fcleanup-gitpod-environments","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiddhant-k-code%2Fcleanup-gitpod-environments/lists"}