-
Notifications
You must be signed in to change notification settings - Fork 1
80 lines (67 loc) · 2.02 KB
/
plan.yml
File metadata and controls
80 lines (67 loc) · 2.02 KB
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
75
76
77
78
79
80
name: Plan
on:
workflow_dispatch:
pull_request:
branches:
- main
jobs:
static:
name: Plan
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Terraform Setup
uses: hashicorp/setup-terraform@v3
- name: Restore Terraform Cache
uses: actions/cache/restore@v4
with:
path: |
.terraform
.terraform.lock.hcl
key: terraform
- name: Terraform Init
env:
TF_TOKEN_app_terraform_io: ${{ secrets.TF_TOKEN_app_terraform_io }}
run: terraform init -input=false
- name: Save Terraform Cache
uses: actions/cache/save@v4
with:
path: |
.terraform
.terraform.lock.hcl
key: terraform
- name: Restore Defaults Cache
uses: actions/cache/restore@v4
with:
path: defaults.yaml
key: defaults
- name: Terraform Plan
id: plan
env:
TF_TOKEN_app_terraform_io: ${{ secrets.TF_TOKEN_app_terraform_io }}
ACI_URL: ${{ secrets.ACI_URL }}
ACI_USERNAME: ${{ secrets.ACI_USERNAME }}
ACI_PASSWORD: ${{ secrets.ACI_PASSWORD }}
run: terraform plan -input=false -no-color
- name: Add Pull Request Comment
uses: actions/github-script@v7
env:
PLAN: "terraform\n${{ steps.plan.outputs.stdout }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `#### Terraform Plan\`${{ steps.plan.outcome }}\`
<details><summary>Show Plan</summary>
\`\`\`\n
${process.env.PLAN}
\`\`\`
</details>
*Pusher: @${{ github.actor }}*`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})