Create HydroServer Google Cloud Deployment #41
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: Create HydroServer Google Cloud Deployment | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Enter a deployment environment name.' | |
required: true | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
setup-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 | |
id: plan | |
run: terraform plan -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 Status | |
if: steps.plan.outcome == 'failure' | |
run: exit 1 | |
- name: Terraform Apply | |
run: terraform apply -auto-approve -input=false -var instance="${{ github.event.inputs.environment }}" -var region="${{ vars.GCP_REGION }}" -var project_id="${{ vars.GCP_PROJECT_ID }}" |