Skip to content

Commit dba6795

Browse files
authored
Merge pull request #36 from Homebrew/workflow
workflows: add workflow to apply changes
2 parents cf4654a + a82a935 commit dba6795

File tree

1 file changed

+90
-2
lines changed

1 file changed

+90
-2
lines changed

.github/workflows/ci.yml

Lines changed: 90 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ concurrency:
1010
cancel-in-progress: true
1111

1212
jobs:
13-
opentofu:
14-
name: OpenTofu
13+
opentofu-plan-pull-request:
14+
name: OpenTofu Plan Pull Request
15+
if: ${{ github.event_name == 'pull_request' }}
1516
runs-on: ubuntu-latest
1617
permissions:
1718
contents: read
@@ -20,6 +21,8 @@ jobs:
2021
TFC_AWS_RUN_ROLE_ARN: ${{ secrets.amazon_role }}
2122
steps:
2223
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24+
with:
25+
persist-credentials: false
2326

2427
- uses: opentofu/setup-opentofu@592200bd4b9bbf4772ace78f887668b1aee8f716 # v1.0.5
2528

@@ -59,6 +62,89 @@ jobs:
5962
-var-file .tfvars \
6063
-var='email_overrides=${{ secrets.email_overrides }}'
6164
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+
62148
trivy:
63149
name: Trivy
64150
runs-on: ubuntu-latest
@@ -69,6 +155,8 @@ jobs:
69155
steps:
70156
- name: Checkout code
71157
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
158+
with:
159+
persist-credentials: false
72160

73161
- name: Run Trivy vulnerability scanner in IaC mode
74162
uses: aquasecurity/trivy-action@6c175e9c4083a92bbca2f9724c8a5e33bc2d97a5 # v0.30.0

0 commit comments

Comments
 (0)