Skip to content
name: Apply Terraform on Google Cloud
#on: #todo revert
# workflow_run:
# workflows: ["Build and Push Docker Image"]
# types:
# - completed
on:
push:
branches:
- master
- dev
jobs:
terraform:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up gcloud CLI
uses: google-github-actions/[email protected]
with:
service_account_key: ${{ secrets.GCP_SA_KEY }}
project_id: ${{ secrets.GCP_PROJECT_ID }}
- name: Create Service Account Key File
run: echo '${{ secrets.GCP_SA_KEY }}' > gcp-key.json
- name: Activate Google Cloud service account
run: gcloud auth activate-service-account --key-file=gcp-key.json
- name: Install Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.0.0
- name: Terraform Init
working-directory: infra/prod
run: terraform init
- name: Terraform Apply
working-directory: infra/prod
run: |
terraform plan -out=tfplan
terraform apply -input=false tfplan
env:
GOOGLE_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}