Update nonprod Terraform to GC3 #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check and validate changes | |
on: | |
pull_request: | |
branches: | |
- main | |
paths: | |
- '**.tf' | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
name: Terraform fmt check | |
outputs: | |
CHECK_STATUS: "${{ env.CHECK_STATUS }}" | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Configure Terraform | |
uses: hashicorp/setup-terraform@v2 | |
- name: Run Terraform fmt | |
run: | | |
set +e | |
echo "CHECK_STATUS=0" >> $GITHUB_ENV | |
for tf_file in $(find . -name '*.tf' -not -path "*/.*"); do | |
echo "Checking Terraform fmt on ${tf_file}..." | |
if [[ $tf_file == *.tf ]]; then | |
terraform fmt -check $tf_file | |
FMT_STATUS=$(echo $?) | |
if [[ $FMT_STATUS -ne 0 ]]; then | |
echo "❌ Terraform fmt failed - ${tf_file}" >> $GITHUB_STEP_SUMMARY | |
echo "CHECK_STATUS=1" >> $GITHUB_ENV | |
fi | |
fi | |
done | |
- name: Process check | |
if: always() | |
run: exit $CHECK_STATUS |