mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 14:55:50 +00:00
fix terraform ci
This commit is contained in:
parent
4155e95725
commit
28f340097f
1 changed files with 59 additions and 0 deletions
59
.github/workflows/terraform-ci.yml
vendored
Normal file
59
.github/workflows/terraform-ci.yml
vendored
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
name: Terraform-CI
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- dev
|
||||||
|
- master
|
||||||
|
paths:
|
||||||
|
- 'terraform/**'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
terraform-test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.ref == 'refs/heads/dev'
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
working-directory: ./terraform
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Setup Terraform
|
||||||
|
uses: hashicorp/setup-terraform@v3
|
||||||
|
with:
|
||||||
|
terraform_version: 1.9.8
|
||||||
|
- name: Validate Terraform Configuration
|
||||||
|
run: terraform init
|
||||||
|
env:
|
||||||
|
GOOGLE_CREDENTIALS: ${{ secrets.GCP_JSON }}
|
||||||
|
- name: Replace secret
|
||||||
|
run: sed -i "s/POSTGRES_PASSWORD/${{ secrets.POSTGRES_PASSWORD }}/" main.tf
|
||||||
|
- name: Dry run Terraform
|
||||||
|
run: terraform plan -var-file=variables.tfvars
|
||||||
|
env:
|
||||||
|
GOOGLE_CREDENTIALS: ${{ secrets.GCP_JSON }}
|
||||||
|
|
||||||
|
terraform-deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
working-directory: ./terraform
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Setup Terraform
|
||||||
|
uses: hashicorp/setup-terraform@v3
|
||||||
|
with:
|
||||||
|
terraform_version: 1.9.8
|
||||||
|
- name: Validate Terraform Configuration
|
||||||
|
run: terraform init
|
||||||
|
env:
|
||||||
|
GOOGLE_CREDENTIALS: ${{ secrets.GCP_JSON }}
|
||||||
|
- name: Replace secret
|
||||||
|
run: sed -i "s/POSTGRES_PASSWORD/${{ secrets.POSTGRES_PASSWORD }}/" main.tf
|
||||||
|
- name: Deploy Terraform
|
||||||
|
run: terraform apply -var-file=variables.tfvars -auto-approve
|
||||||
|
env:
|
||||||
|
GOOGLE_CREDENTIALS: ${{ secrets.GCP_JSON }}
|
Loading…
Reference in a new issue