-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (79 loc) · 2.54 KB
/
apply.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Apply Terraform
on:
push:
branches:
- master
env:
opentofu_version: "1.6.0-alpha3"
jobs:
plan:
name: Plan
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v2
- uses: azure/[email protected]
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
allow-no-subscriptions: true
- name: Download OpenTofu
run: |
curl -LO https://github.com/opentofu/opentofu/releases/download/v${{ env.opentofu_version }}/tofu_${{ env.opentofu_version }}_linux_amd64.zip
unzip tofu_${{ env.opentofu_version }}_linux_amd64.zip -d tofu
sudo mv tofu/tofu /usr/local/bin/tofu
- name: Unlock encrypted files
run: |
export SECRET_PASS="${{ secrets.SECRET_PASS }}"
make unlock
- name: Terraform init
run: |
tofu init --backend-config secrets/backend.hcl
- name: Terraform Plan
run: |
tofu plan -out plan-${{ github.sha }}
- name: Upload plan
uses: actions/upload-artifact@v3
with:
name: plan
path: "plan-${{ github.sha }}"
apply:
name: Apply
runs-on: ubuntu-latest
needs: plan
environment: prod
permissions:
id-token: write
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Download OpenTofu
run: |
curl -LO https://github.com/opentofu/opentofu/releases/download/v${{ env.opentofu_version }}/tofu_${{ env.opentofu_version }}_linux_amd64.zip
unzip tofu_${{ env.opentofu_version }}_linux_amd64.zip -d tofu
sudo mv tofu/tofu /usr/local/bin/tofu
- name: Download plan
uses: actions/download-artifact@v3
with:
name: plan
- uses: azure/[email protected]
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
allow-no-subscriptions: true
- name: Unlock encrypted files
run: |
export SECRET_PASS="${{ secrets.SECRET_PASS }}"
make unlock
- name: Terraform init
run: |
tofu init --backend-config secrets/backend.hcl
- name: Apply
run: |
tofu apply plan-${{ github.sha }}