Skip to content

Instantly share code, notes, and snippets.

@MarkWarneke
Last active December 22, 2020 11:47
Show Gist options
  • Save MarkWarneke/8d484fbe5f4456d6b50c174e20298995 to your computer and use it in GitHub Desktop.
Save MarkWarneke/8d484fbe5f4456d6b50c174e20298995 to your computer and use it in GitHub Desktop.
Update Pull Request adds a comment to the pull request with the results of the format, init and plan steps. In addition, it displays the plan output (steps.plan.outputs.stdout). This allows your team to review the results of the plan directly in the PR. Based on https://learn.hashicorp.com/tutorials/terraform/github-actions
- uses: hashicorp/setup-terraform@v1
- name: Update Pull Request
uses: actions/github-script@0.9.0
if: github.event_name == 'pull_request'
env:
PLAN: "${{ steps.plan.outputs.stdout }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `
Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`
#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\`
#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
#### Terraform Plan 📖\`${{ steps.plan.outcome }}\`
<details><summary>Show Plan</summary>
\n
\`\`\`terraform
${process.env.PLAN}
\`\`\`
\n
</details>
`;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment