GitHub Action: Terraform Pull Request Report Generator
Updates Pull Requests with visual diff of Terraform Plan changes
![semantic](https://camo.githubusercontent.com/39d6403df72c843f9dc9ab0a20f701d287019c092d93dfaacc3647b1d499f47e/68747470733a2f2f62616467656e2e6e65742f62616467652f2546302539462539332541362f73656d616e746963616c6c7925323072656c65617365642f626c7565)
name: terraform-plan
on:
pull_request:
jobs:
terraform-plan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: hashicorp/setup-terraform@v1
with:
terraform_wrapper: false
- run: terraform init
- run: terraform plan -lock=false -out terraform.plan
# generate plain output
- run: terraform show -no-color terraform.plan > terraform.text
# generate json output
- run: terraform show -json terraform.plan > terraform.json
- uses: ahmadnassri/action-terraform-report@v3
with:
# tell the action the plan outputs
terraform-text: ${{ github.workspace }}/terraform.text
terraform-json: ${{ github.workspace }}/terraform.json
remove-stale-reports: true
Note: Ensure terraform_wrapper
is set to false
to better capture the output into a file (or use your own method)
input |
required |
default |
description |
terraform-text |
✅ |
- |
path to the file resulting from the output of terraform show /path/to/plan |
terraform-json |
✅ |
- |
path to the file resulting from the output of terraform show -json /path/to/plan |
github-token |
❌ |
github.token |
The GitHub token used to post comments on pull requests |
show-plan |
❌ |
true |
include the terraform plan view in the final output? |
show-diff |
❌ |
false |
include the diff view in the final output? |
remove-stale-reports |
❌ |
false |
remove report comments for old commits? |
Pull Request Comment (default) |
![](./docs/1.png) |
Pull Request Comment (Plan) |
![](./docs/2.png) |
Pull Request Comment (Diff) |
![](./docs/3.png) |
Author: Ahmad Nassri •
Twitter: @AhmadNassri