Create Terraform Deploy to GCP.yaml

initial setup
This commit is contained in:
BushraS-Protean
2025-05-29 11:33:40 +05:30
committed by GitHub
parent 11a3affa18
commit 5c5a8b6726

View File

@@ -0,0 +1,41 @@
name: Terraform Deploy to GCP
on:
push:
branches:
- main
jobs:
terraform:
name: Deploy with Terraform on GCP
runs-on: ubuntu-latest
env:
GOOGLE_APPLICATION_CREDENTIALS: ${{ github.workspace }}/gcp-key.json
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.5.0
- name: Authenticate to Google Cloud
run: echo "${{ secrets.GCP_CREDENTIALS }}" > gcp-key.json
shell: bash
- name: Terraform Init
run: terraform init -var="credentials_file=gcp-key.json"
- name: Terraform Validate
run: terraform validate
- name: Terraform Plan
run: terraform plan -var="credentials_file=gcp-key.json" -out=tfplan
- name: Terraform Apply
run: terraform apply -auto-approve tfplan
- name: Clean up credentials file
run: rm -f gcp-key.json