diff --git a/.github/workflows/terraform-plan.yaml b/.github/workflows/terraform-plan.yaml
index 6d4dae0..d151fcd 100644
--- a/.github/workflows/terraform-plan.yaml
+++ b/.github/workflows/terraform-plan.yaml
@@ -33,10 +33,21 @@ jobs:
with:
terraform_wrapper: false
- - name: Terraform fmt
+ - name: Terraform Format
id: fmt
- run: terraform fmt
- continue-on-error: true
+ run: |
+ terraform fmt
+ if ! git diff-index --quiet HEAD; then
+ git config --global user.name '${{ github.event.pull_request.user.login }}'
+ git config --global user.email 'github-actions@census.gov'
+ git commit -am "Autoformatting TF Code"
+ git push
+ echo "auto_format=true" >> $GITHUB_ENV
+ fi
+
+ - name: Autoformat Halt
+ if: env.auto_format == 'true'
+ run: exit 1
- name: Terraform Init
id: init
@@ -44,47 +55,10 @@ jobs:
- name: Terraform Validate
id: validate
- run: terraform validate -no-color
+ run: terraform validate
- name: Terraform Plan
id: plan
- run: terraform plan -no-color
+ run: terraform plan
continue-on-error: true
-# - uses: CSVD/gh-actions-github-script@v6
-# if: github.event_name == 'pull_request'
-# env:
-# PLAN: "terraform\n${{ steps.plan.outputs.stdout }}"
-# with:
-# github-token: ${{ secrets.GH_TOKEN }}
-# script: |
-# const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\`
-# #### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
-# #### Terraform Validation 🤖\`${{ steps.validate.outcome }}\`
-# Validation Output
-
-# \`\`\`\n
-# ${{ steps.validate.outputs.stdout }}
-# \`\`\`
-
-#
-
-# #### Terraform Plan 📖\`${{ steps.plan.outcome }}\`
-
-# Show Plan
-
-# \`\`\`\n
-# ${process.env.PLAN}
-# \`\`\`
-
-#
-
-# *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`*`;
-
-# github.rest.issues.createComment({
-# issue_number: context.issue.number,
-# owner: context.repo.owner,
-# repo: context.repo.repo,
-# body: output
-# })
-