diff --git a/.github/workflows/terraform-test.yml b/.github/workflows/terraform-test.yml index 1055bf3..dd482a9 100644 --- a/.github/workflows/terraform-test.yml +++ b/.github/workflows/terraform-test.yml @@ -33,10 +33,23 @@ jobs: terraform_version: "~>1.6.0" terraform_wrapper: false - - name: Terraform Format + - name: Format Terraform files + run: terraform fmt -recursive id: fmt - run: terraform fmt -check - continue-on-error: false + + - name: Check for file changes + id: check_changes + run: | + git diff --exit-code || echo "changes_detected=true" >> $GITHUB_ENV + + - name: Commit and push changes + if: env.changes_detected == 'true' + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git add . + git commit -m "chore: format terraform files" + git push origin HEAD:${{ github.event.pull_request.head.ref }} - name: Terraform Init id: init