Skip to content

update validation workflow #3

update validation workflow

update validation workflow #3

Workflow file for this run

name: Terraform Validation
on:
push:
branches:
- main
pull_request:
jobs:
find-directories:
name: Find Terraform Directories
runs-on: ubuntu-latest
outputs:
directories: ${{ steps.get-dirs.outputs.dirs }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Find directories with Terraform projects
id: get-dirs
run: |
dirs=$(find . -type f -name "*.tf" -print0 | xargs -0 -n1 dirname | sort -u)
echo "::set-output name=dirs::$(echo $dirs | jq -R -s -c 'split("\n")[:-1]')"
env:
PATH: /usr/bin:/bin
validate:
name: Validate Terraform Projects
needs: find-directories
runs-on: ubuntu-latest
strategy:
matrix:
directory: ${{ fromJson(needs.find-directories.outputs.directories) }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
- name: Validate Terraform in directory
working-directory: ${{ matrix.directory }}
run: |
echo "Validating Terraform configuration in '${{ matrix.directory }}'"
terraform init -backend=false
terraform validate