-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (67 loc) · 2.44 KB
/
plan-on-pr.yaml
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
74
name: Terraform Plan on PR
on:
pull_request:
workflow_dispatch:
permissions:
pull-requests: write
jobs:
terraform-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Terraform fmt
id: fmt
run: |
docker run --platform linux/amd64 \
-v $(pwd):/terraform -w /terraform \
hashicorp/terraform fmt
continue-on-error: false
shell: bash
- name: Terraform Init
id: init
run: |
docker run --platform linux/amd64 \
-e "AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}" \
-e "AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}" \
-v $(pwd):/terraform -w /terraform hashicorp/terraform init -upgrade
continue-on-error: false
shell: bash
- name: Terraform Validate
id: validate
run: |
docker run --platform linux/amd64 \
-v $(pwd):/terraform -w /terraform \
hashicorp/terraform validate -no-color
continue-on-error: false
shell: bash
- name: Terraform Plan
id: plan
run: |
docker run --platform linux/amd64 \
-e "AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}" \
-e "AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}" \
-v $(pwd):/terraform -w /terraform \
hashicorp/terraform plan \
-var="hcloud_token=${{ secrets.HCLOUD_TOKEN }}" \
-no-color -lock=false -out terraform.plan
continue-on-error: true
# generate plain output
- run: |
docker run --platform linux/amd64 \
-e "AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}" \
-e "AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}" \
-v $(pwd):/terraform -w /terraform \
hashicorp/terraform show -no-color terraform.plan > terraform.text
# generate json output
- run: |
docker run --platform linux/amd64 \
-e "AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}" \
-e "AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}" \
-v $(pwd):/terraform -w /terraform \
hashicorp/terraform show -json terraform.plan > terraform.json
- uses: ahmadnassri/action-terraform-report@v4
with:
# tell the action the plan outputs
terraform-text: ${{ github.workspace }}/terraform.text
terraform-json: ${{ github.workspace }}/terraform.json
remove-stale-reports: true