From da17847d115ff1e5987848a1030cfc415b0a3a5c Mon Sep 17 00:00:00 2001 From: Kabir Bolatito Date: Thu, 21 May 2020 10:36:02 -0400 Subject: [PATCH] Update README.md (#11) * Update README.md PR Comment is a big plus to why we opt to use Terraform Github actions. Updated the readme file so that everyone will understand how to take advantage of the terraform concise on PR comment capability * Update README.md updated * Update README.md replaced the existing example --- README.md | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0a21b34..20ba2c2 100644 --- a/README.md +++ b/README.md @@ -81,23 +81,51 @@ steps: Outputs can be used in subsequent steps to comment on the pull request: ```yaml +defaults: + run: + working-directory: ${{ env.tf_actions_working_dir }} steps: +- uses: actions/checkout@v2 - uses: hashicorp/setup-terraform@v1 -- run: terraform init +- name: Terraform fmt + id: fmt + run: terraform fmt + continue-on-error: true -- id: plan +- name: Terraform Init + id: init + run: terraform init + +- name: Terraform Validate + id: validate + run: terraform validate -no-color + +- name: Terraform Plan + id: plan run: terraform plan -no-color + continue-on-error: true - uses: actions/github-script@0.9.0 if: github.event_name == 'pull_request' env: - STDOUT: "```terraform\n${{ steps.plan.outputs.stdout }}```" + PLAN: "terraform\n${{ steps.plan.outputs.stdout }}" with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const output = `
tf plan:\n\n${process.env.STDOUT}\n\n
`; - + const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\` + #### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\` + #### Terraform Validation 🤖${{ steps.validate.outputs.stdout }} + #### Terraform Plan 📖\`${{ steps.plan.outcome }}\` + +
Show Plan + + \`\`\`${process.env.PLAN}\`\`\` + +
+ + *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`*`; + github.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner,