Skip to content

update validation workflow #2

update validation workflow

update validation workflow #2

Workflow file for this run

name: Terraform Validation
on:
push:
branches:
- main
pull_request:
jobs:
terraform-validate:
name: Validate Terraform
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
- name: Find Terraform directories
id: find-terraform-dirs
run: |
dirs=$(find . -type f -name "main.tf" -exec dirname {} \; | sort | uniq)
echo "::set-output name=dirs::${dirs}"
- name: Find and validate all Terraform configurations
shell: bash
run: |
# Find all directories containing *.tf files
find . -type f -name "*.tf" -print0 | xargs -0 -n1 dirname | sort -u | while IFS= read -r dir; do
echo "Validating Terraform configuration in '${dir}'"
cd "${dir}" || exit
# Initialize Terraform without backend to prevent remote state issues
terraform init -backend=false
# Validate the configuration
terraform validate
# Return to the root directory
cd - > /dev/null
done