Teardown HydroServer GCP Cloud Deployment #4
This file contains 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: Teardown HydroServer GCP Cloud Deployment | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Enter a deployment environment name.' | |
required: true | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
teardown-deployment: | |
runs-on: ubuntu-20.04 | |
environment: ${{ github.event.inputs.environment }} | |
defaults: | |
run: | |
working-directory: ./terraform/gcp | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: Configure GCP Credentials | |
uses: google-github-actions/auth@v2 | |
with: | |
project_id: ${{ vars.GCP_PROJECT_ID }} | |
workload_identity_provider: ${{ vars.GCP_IDENTITY_PROVIDER }} | |
service_account: ${{ vars.GCP_SERVICE_ACCOUNT }} | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v1 | |
- name: Terraform Init | |
run: terraform init -backend-config="impersonate_service_account=${{ vars.GCP_SERVICE_ACCOUNT }}" -backend-config="bucket=${{ vars.TERRAFORM_BUCKET }}" -backend-config="prefix=state/gcp_application_${{ github.event.inputs.environment }}" | |
- name: Terraform Plan Destroy | |
id: plan_destroy | |
run: terraform plan -destroy -no-color -input=false -var instance="${{ github.event.inputs.environment }}" -var region="${{ vars.GCP_REGION }}" -var project_id="${{ vars.GCP_PROJECT_ID }}" | |
continue-on-error: true | |
- name: Terraform Plan Destroy Status | |
if: steps.plan_destroy.outcome == 'failure' | |
run: exit 1 | |
- name: Terraform Destroy | |
run: terraform destroy -auto-approve -input=false -var instance="${{ github.event.inputs.environment }}" -var region="${{ vars.GCP_REGION }}" -var project_id="${{ vars.GCP_PROJECT_ID }}" |