From 9198eed7044731ca2646ec4b7a3a1c0591304fc3 Mon Sep 17 00:00:00 2001 From: David John Arnold Jr Date: Fri, 9 Aug 2024 15:25:00 -0700 Subject: [PATCH] Update terraform-plan.yaml --- .github/workflows/terraform-plan.yaml | 58 ++++++++------------------- 1 file changed, 16 insertions(+), 42 deletions(-) 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 -# }) -