GitHub Action
Terraform Plan Comment
GitHub Action to post the output of terraform plan
to a pull request comment.
- Generate a structured, "markdown-native" representation of the plan
- Obtain a high-level overview via foldable sections
- Do not lose any information compared to the output of
terraform plan
- Post the plan to pull requests as a "sticky comment"
- Run as a "native" JavaScript action rather than launching a Docker container
- Use with or without the Terraform wrapper script provided by hashicorp/setup-terraform
- name: Setup terraform
uses: hashicorp/setup-terraform@v3
- name: Initialize
run: terraform init
- name: Plan
run: terraform plan -out .planfile
- name: Post PR comment
uses: borchero/terraform-plan-comment@v1
with:
token: ${{ github.token }}
planfile: .planfile
This action provides a few input parameters that allow for customization:
Required input parameter to access the GitHub API for posting a pull request comment. Can be provided as
${{ github.token }}
, ${{ env.GITHUB_TOKEN }}
or some personal access token with appropriate permissions.
If using the workflow-provided token, make sure that your workflow/job has write-permissions to pull requests.
The path to the planfile generated by terraform plan
which holds the information about which changes ought to be
applied.
The command to execute to call the Terraform binary. Defaults to terraform
. You likely don't need to augment this
unless terraform
cannot be found in the PATH
.
The directory where the Terraform binary ought to be called. Defaults to $GITHUB_WORKSPACE
and must be specified if
terraform init
has been run in a different directory. Should be specified relative to $GITHUB_WORKSPACE
.
Important
planfile
must be specified relative to the working directory.
A custom identifier for the Terraform execution. This allows to distinguish multiple Terraform runs: each sticky pull request comment is tied to an ID.