Garbage Collector #98
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Garbage Collector" | |
| on: | |
| schedule: | |
| - cron: "0 */12 * * *" | |
| workflow_dispatch: | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| cleanup: | |
| name: "Delete Stale Cloud Resources" | |
| runs-on: ubuntu-slim | |
| env: | |
| MAX_AGE_HOURS: "12" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| - name: Log into Azure using OIDC | |
| uses: azure/login@v3 | |
| with: | |
| client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
| tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
| subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
| - name: Log into AWS using OIDC | |
| uses: aws-actions/configure-aws-credentials@v6 | |
| with: | |
| role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} | |
| aws-region: eu-west-2 | |
| - name: Log into GCP using OIDC | |
| id: gcp-auth | |
| uses: google-github-actions/auth@v3 | |
| with: | |
| workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} | |
| service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }} | |
| - name: Setup Go | |
| uses: actions/setup-go@v7 | |
| with: | |
| go-version-file: garbage-collector/go.mod | |
| - name: Run garbage collector (delete) | |
| env: | |
| AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
| GCP_PROJECT_ID: ${{ steps.gcp-auth.outputs.project_id }} | |
| run: go run . --dry-run=false | |
| working-directory: garbage-collector |