@@ -10,8 +10,9 @@ concurrency:
10
10
cancel-in-progress : true
11
11
12
12
jobs :
13
- opentofu :
14
- name : OpenTofu
13
+ opentofu-plan-pull-request :
14
+ name : OpenTofu Plan Pull Request
15
+ if : ${{ github.event_name == 'pull_request' }}
15
16
runs-on : ubuntu-latest
16
17
permissions :
17
18
contents : read
20
21
TFC_AWS_RUN_ROLE_ARN : ${{ secrets.amazon_role }}
21
22
steps :
22
23
- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24
+ with :
25
+ persist-credentials : false
23
26
24
27
- uses : opentofu/setup-opentofu@592200bd4b9bbf4772ace78f887668b1aee8f716 # v1.0.5
25
28
59
62
-var-file .tfvars \
60
63
-var='email_overrides=${{ secrets.email_overrides }}'
61
64
65
+ opentofu-plan :
66
+ name : OpenTofu Plan
67
+ if : github.ref == 'refs/heads/main'
68
+ runs-on : ubuntu-latest
69
+ permissions :
70
+ contents : read
71
+ id-token : write
72
+ env :
73
+ TFC_AWS_RUN_ROLE_ARN : ${{ secrets.amazon_role }}
74
+ steps :
75
+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
76
+ with :
77
+ persist-credentials : false
78
+
79
+ - uses : opentofu/setup-opentofu@592200bd4b9bbf4772ace78f887668b1aee8f716 # v1.0.5
80
+
81
+ - name : Configure AWS Credentials
82
+ uses : aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # v4.1.0
83
+ with :
84
+ aws-region : us-east-1
85
+ role-to-assume : ${{ secrets.amazon_role }}
86
+
87
+ - name : OpenTofu Init
88
+ id : init
89
+ run : tofu init
90
+
91
+ - name : OpenTofu Plan
92
+ env :
93
+ GITHUB_APP_ID : ${{ secrets.TF_GH_APP }}
94
+ GITHUB_APP_INSTALLATION_ID : ${{ secrets.TF_GH_APP_INSTALL }}
95
+ GITHUB_APP_PEM_FILE : ${{ secrets.TF_GH_APP_PEM }}
96
+ DNSIMPLE_ACCOUNT : ${{ secrets.TF_DNSIMPLE_ACCOUNT }}
97
+ DNSIMPLE_TOKEN : ${{ secrets.TF_DNSIMPLE_TOKEN }}
98
+ run : |
99
+ tofu plan -no-color -detailed-exitcode \
100
+ -var-file .tfvars \
101
+ -var='email_overrides=${{ secrets.email_overrides }}' \
102
+ -out=tfplan
103
+
104
+ - name : Upload Plan Artifact
105
+ uses : actions/upload-artifact@v4
106
+ with :
107
+ name : tfplan
108
+ path : tfplan
109
+
110
+
111
+ opentofu-apply :
112
+ name : OpenTofu Apply
113
+ if : github.ref == 'refs/heads/main'
114
+ runs-on : ubuntu-latest
115
+ environment : ' production'
116
+ needs : ' opentofu-plan'
117
+ permissions :
118
+ contents : read
119
+ id-token : write
120
+ env :
121
+ TFC_AWS_RUN_ROLE_ARN : ${{ secrets.amazon_role }}
122
+ steps :
123
+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
124
+ with :
125
+ persist-credentials : false
126
+
127
+ - uses : opentofu/setup-opentofu@592200bd4b9bbf4772ace78f887668b1aee8f716 # v1.0.5
128
+
129
+ - name : Configure AWS Credentials
130
+ uses : aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # v4.1.0
131
+ with :
132
+ aws-region : us-east-1
133
+ role-to-assume : ${{ secrets.amazon_role }}
134
+
135
+ - name : OpenTofu Init
136
+ id : init
137
+ run : tofu init
138
+
139
+ - name : Download Plan Artifact
140
+ uses : actions/download-artifact@v4
141
+ with :
142
+ name : tfplan
143
+
144
+ - name : OpenTofu Apply
145
+ run : |
146
+ tofu apply -no-color "tfplan"
147
+
62
148
trivy :
63
149
name : Trivy
64
150
runs-on : ubuntu-latest
69
155
steps :
70
156
- name : Checkout code
71
157
uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
158
+ with :
159
+ persist-credentials : false
72
160
73
161
- name : Run Trivy vulnerability scanner in IaC mode
74
162
uses : aquasecurity/trivy-action@6c175e9c4083a92bbca2f9724c8a5e33bc2d97a5 # v0.30.0
0 commit comments