Refactor Terraform CI/CD workflow to support all branches and improve structure
Some checks failed
Terraform CI/CD / terraform (push) Has been cancelled

This commit is contained in:
2025-12-23 12:04:45 +01:00
parent dfdb321058
commit 321263daf6

View File

@@ -1,18 +1,50 @@
name: "Terraform CI/CD" name: Terraform CI/CD
on: on:
push: push:
branches: branches:
- main - "**"
paths: pull_request:
- terraform/**
jobs: jobs:
terraform: terraform:
name: "Terraform Infrastructure Change Management" runs-on: ssot-runner
runs-on: ssot-runner
defaults: steps:
run: - name: Checkout repository
shell: bash uses: actions/checkout@v4
# We keep Terraform files in the terraform directory.
working-directory: ./terraform - name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.6.6
- name: Terraform Init
run: terraform init -input=false
- name: Terraform Format
run: terraform fmt -check -recursive
- name: Terraform Validate
run: terraform validate
- name: Terraform Plan
run: |
terraform plan \
-input=false \
-out=tfplan
- name: Show Terraform Plan
run: terraform show -no-color tfplan > plan.txt
- name: Upload plan artifact
uses: actions/upload-artifact@v3
with:
name: terraform-plan
path: |
tfplan
plan.txt
- name: Terraform Apply
if: github.ref == 'refs/heads/main'
run: terraform apply -input=false -auto-approve tfplan