From 5c5a8b67264c9fd77bcc4fafce1f6d2de3d3bd8e Mon Sep 17 00:00:00 2001 From: BushraS-Protean Date: Thu, 29 May 2025 11:33:40 +0530 Subject: [PATCH] Create Terraform Deploy to GCP.yaml initial setup --- .../workflows/Terraform Deploy to GCP.yaml | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/Terraform Deploy to GCP.yaml diff --git a/.github/workflows/Terraform Deploy to GCP.yaml b/.github/workflows/Terraform Deploy to GCP.yaml new file mode 100644 index 0000000..86a5080 --- /dev/null +++ b/.github/workflows/Terraform Deploy to GCP.yaml @@ -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