73 lines (59 loc) · 2.2 KB
/
demo.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Demo Workflow
on:
workflow_dispatch:
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false
- name: Install terraform-plan-summary
run: |
REPO="dineshba/terraform-plan-summary"
curl -LO https://github.com/$REPO/releases/latest/download/tf-summarize_linux_amd64.zip
tmpDir=$(mktemp -d -t tmp.XXXXXXXXXX)
mv tf-summarize_linux_amd64.zip $tmpDir
cd $tmpDir
unzip tf-summarize_linux_amd64.zip
chmod +x tf-summarize
echo $PWD >> $GITHUB_PATH
- name: Print tf-summarize version and help
run: |
tf-summarize -v
tf-summarize -h
- name: Terraform Init
run: terraform init
working-directory: ./example
- name: Terraform Plan
run: terraform plan -out=tfplan -refresh=false # -refresh=false is only for demo workflow
working-directory: ./example
- name: summary in table format
run: terraform show -json tfplan | tf-summarize
working-directory: ./example
- name: summary in tree format
run: terraform show -json tfplan | tf-summarize -tree
working-directory: ./example
- name: summary in separate tree format
run: terraform show -json tfplan | tf-summarize -separate-tree
working-directory: ./example
- name: summary in draw table format
run: terraform show -json tfplan | tf-summarize -tree -draw
working-directory: ./example
- name: summary in draw table format
run: |
rm -rf tf-summarize-table-output.md
echo "## tf-summarize output:" > tf-summarize-table-output.md
echo "" >> tf-summarize-table-output.md
terraform show -json tfplan | tf-summarize -md >> tf-summarize-table-output.md
working-directory: ./example
- name: Create comment with terraform plan summary
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: 19 # ${{ github.event.pull_request.number }} to get the pull request number which triggered this run
body-file: './example/tf-summarize-table-output.md'