Update onix-gcp-terraform-deploy.yml

This commit is contained in:
AbhishekHS220
2025-06-02 12:38:28 +05:30
committed by GitHub
parent 681f1846a6
commit 29ac7111b7

View File

@@ -4,11 +4,9 @@ on:
workflow_dispatch: # Manual trigger workflow_dispatch: # Manual trigger
jobs: jobs:
terraform: plan:
name: Deploy GCP Infrastructure name: Terraform Plan Only
runs-on: ubuntu-latest runs-on: ubuntu-latest
#env:
# GOOGLE_APPLICATION_CREDENTIALS: ${{ github.workspace }}/gcp-key.json
steps: steps:
- name: Checkout this repository - name: Checkout this repository
@@ -18,37 +16,25 @@ jobs:
run: | run: |
git clone https://${{ secrets.GERRIT_USERNAME }}:${{ secrets.GERRIT_PAT }}@open-networks.googlesource.com/onix-dev gerrit-repo git clone https://${{ secrets.GERRIT_USERNAME }}:${{ secrets.GERRIT_PAT }}@open-networks.googlesource.com/onix-dev gerrit-repo
- name: Set up Terraform - name: Set up Terraform
uses: hashicorp/setup-terraform@v3 uses: hashicorp/setup-terraform@v3
with: with:
terraform_version: 1.5.0 terraform_version: 1.5.0
- name: Authenticate to Google Cloud - name: Authenticate to Google Cloud
run: echo "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_JSON }}" > gcp-key.json run: echo '${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_JSON }}' > gcp-key.json
- name: Terraform Init with backend - name: Terraform Init with backend
working-directory: ./onix-dev/Terraform working-directory: ./gerrit-repo/Terraform
run: | run: |
terraform init \ terraform init \
-backend-config="bucket=your-backend-bucket-name" \ -backend-config="bucket=beckn-state-bucket-bs" \
-backend-config="prefix=terraform/state" \ -backend-config="prefix=onix-terraform/state" \
-backend-config="credentials=${{ github.workspace }}/gcp-key.json" -backend-config="credentials=${{ github.workspace }}/gcp-key.json"
- name: Terraform Plan - name: Terraform Plan
working-directory: ./onix-dev/Terraform working-directory: ./gerrit-repo/Terraform
run: terraform plan -out=tfplan -var="credentials_file=${{ github.workspace }}/gcp-key.json" run: terraform plan -var="credentials_file=${{ github.workspace }}/gcp-key.json"
- name: Wait for Manual Approval
uses: hmarr/auto-approve-action@v2
if: false # prevents automatic approval
with:
github-token: ${{ secrets.PAT_GITHUB }}
- name: Terraform Apply
working-directory: ./onix-dev/Terraform
run: terraform apply tfplan
- name: Clean up credentials - name: Clean up credentials
run: rm -f gcp-key.json run: rm -f gcp-key.json