name: Clean on: workflow_dispatch: pull_request: branches: - main types: [ closed ] env: NETWORK: Mainnet PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} REGION: us-central1 ZONE: us-central1-a jobs: delete: name: Delete test deployments runs-on: ubuntu-latest needs: [ build ] steps: - uses: actions/checkout@v2.4.0 with: persist-credentials: false - name: Inject slug/short variables uses: rlespinasse/github-slug-action@v4 # Setup gcloud CLI - name: Authenticate to Google Cloud id: auth uses: google-github-actions/auth@v0.5.0 with: credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }} - 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