2022-03-09 13:10:05 -08:00
|
|
|
name: Clean
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- main
|
2022-04-11 22:06:37 -07:00
|
|
|
types: [closed]
|
2022-03-09 13:10:05 -08:00
|
|
|
|
|
|
|
env:
|
|
|
|
NETWORK: Mainnet
|
2022-03-18 14:25:35 -07:00
|
|
|
PROJECT_ID: zealous-zebra
|
2022-03-09 13:10:05 -08:00
|
|
|
REGION: us-central1
|
|
|
|
ZONE: us-central1-a
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
delete:
|
|
|
|
name: Delete test deployments
|
|
|
|
runs-on: ubuntu-latest
|
2022-03-18 14:25:35 -07:00
|
|
|
permissions:
|
|
|
|
contents: 'read'
|
|
|
|
id-token: 'write'
|
2022-03-09 13:10:05 -08:00
|
|
|
steps:
|
|
|
|
- name: Inject slug/short variables
|
|
|
|
uses: rlespinasse/github-slug-action@v4
|
2022-03-21 16:07:01 -07:00
|
|
|
with:
|
|
|
|
short-length: 7
|
2022-03-09 13:10:05 -08:00
|
|
|
|
|
|
|
# Setup gcloud CLI
|
|
|
|
- name: Authenticate to Google Cloud
|
|
|
|
id: auth
|
2022-04-06 12:28:39 -07:00
|
|
|
uses: google-github-actions/auth@v0.7.0
|
2022-03-09 13:10:05 -08:00
|
|
|
with:
|
2022-03-18 14:25:35 -07:00
|
|
|
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'
|
2022-03-09 13:10:05 -08:00
|
|
|
|
|
|
|
- name: Delete test instance
|
|
|
|
continue-on-error: true
|
|
|
|
run: |
|
|
|
|
TEST_INSTANCES=$(gcloud compute instances list --filter="${{ env.GITHUB_REF_SLUG_URL }}" --format='value(NAME)')
|
2022-04-11 22:06:37 -07:00
|
|
|
for instance in ${TEST_INSTANCES}; do gcloud compute instances delete $instance --zone "${{ env.ZONE }}" --delete-disks all --quiet; done
|