name: Clean on: workflow_dispatch: pull_request: branches: - main types: [ closed ] env: NETWORK: Mainnet PROJECT_ID: zealous-zebra REGION: us-central1 ZONE: us-central1-a jobs: delete: name: Delete test deployments runs-on: ubuntu-latest permissions: contents: 'read' id-token: 'write' steps: - name: Inject slug/short variables uses: rlespinasse/github-slug-action@v4 with: short-length: 7 # Setup gcloud CLI - name: Authenticate to Google Cloud id: auth uses: google-github-actions/auth@v0.6.0 with: workload_identity_provider: 'projects/143793276228/locations/global/workloadIdentityPools/github-actions/providers/github-oidc' service_account: 'github-service-account@zealous-zebra.iam.gserviceaccount.com' token_format: 'access_token' - name: Delete test instance continue-on-error: true run: | TEST_INSTANCES=$(gcloud compute instances list --filter="${{ env.GITHUB_REF_SLUG_URL }}" --format='value(NAME)') for instance in ${TEST_INSTANCES}; do gcloud compute instances delete $instance --zone "${{ env.ZONE }}" --delete-disks all --quiet; done