Skip to content

feat: Update actions to deploy to GCP #32

feat: Update actions to deploy to GCP

feat: Update actions to deploy to GCP #32

Workflow file for this run

name: Terraform CI/CD
on:
push:
branches:
- main
workflow_dispatch:
jobs:
plan:
name: Terraform Plan
runs-on: ubuntu-latest
outputs:
plan-exit-code: ${{ steps.plan.outcome }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Authenticate with GCP
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: latest
- name: Change Directory
run: cd terraform
- name: Initialize Terraform
run: terraform init
- name: Terraform Plan
id: plan
run: terraform plan -out=tfplan
continue-on-error: false
- name: Upload Plan Artifact
uses: actions/upload-artifact@v4
with:
name: tfplan
path: tfplan
apply:
name: Terraform Apply
needs: plan
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Authenticate with GCP
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: latest
- name: Download Plan Artifact
uses: actions/download-artifact@v4
with:
name: tfplan
- name: Change Directory
run: cd terraform
- name: Initialize Terraform
run: terraform init
- name: Apply Terraform Changes
run: terraform apply -auto-approve tfplan