Last active
December 22, 2020 11:47
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- uses: hashicorp/setup-terraform@v1 | |
- name: Update Pull Request | |
uses: actions/[email protected] | |
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