Skip to content

Commit 7a5d22c

Browse files
committed
ci: Updated plan and deploy jobs to supported layered approach.
1 parent 615240e commit 7a5d22c

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

.github/workflows/deploy.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ name: Deploy infrastructure changes
33
on:
44
workflow_dispatch:
55
inputs:
6+
config:
7+
description: OpenTofu configuration to deploy.
8+
default: service
9+
required: true
10+
type: choice
11+
options:
12+
- foundation
13+
- networking
14+
- service
615
environment:
716
description: Environment to deploy to.
817
default: development
@@ -13,9 +22,6 @@ permissions:
1322
contents: read
1423
id-token: write
1524

16-
env:
17-
CONFIG_PATH: ./tofu/config/development
18-
1925
# TODO: Add an approval step between plan and deploy.
2026
jobs:
2127
plan:
@@ -80,10 +86,10 @@ jobs:
8086
uses: actions/download-artifact@v4
8187
with:
8288
name: tfplan
83-
path: ${{ env.CONFIG_PATH }}
89+
path: ./tofu/config/${{ inputs.config }}
8490
- name: Initialize OpenTofu
85-
working-directory: ${{ env.CONFIG_PATH }}
91+
working-directory: ./tofu/config/${{ inputs.config }}
8692
run: tofu init
8793
- name: Deploy changes
88-
working-directory: ${{ env.CONFIG_PATH }}
94+
working-directory: ./tofu/config/${{ inputs.config }}
8995
run: tofu apply tfplan

.github/workflows/plan.yaml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ name: Plan infrastructure changes
33
on:
44
workflow_call:
55
inputs:
6+
config:
7+
description: OpenTofu configuration to plan.
8+
default: service
9+
required: true
10+
type: string
611
environment:
712
description: Environment to plan on.
813
default: development
@@ -22,6 +27,15 @@ on:
2227
TF_VAR_VPC_PUBLIC_SUBNET_CIDRS:
2328
workflow_dispatch:
2429
inputs:
30+
config:
31+
description: OpenTofu configuration to plan.
32+
default: service
33+
required: true
34+
type: choice
35+
options:
36+
- foundation
37+
- networking
38+
- service
2539
environment:
2640
description: Environment to plan on.
2741
default: development
@@ -32,9 +46,6 @@ permissions:
3246
contents: read
3347
id-token: write
3448

35-
env:
36-
CONFIG_PATH: ./tofu/config/development
37-
3849
jobs:
3950
plan:
4051
name: Plan changes to ${{ inputs.environment || 'development' }}
@@ -77,19 +88,19 @@ jobs:
7788
fi
7889
done
7990
- name: Initialize OpenTofu
80-
working-directory: ${{ env.CONFIG_PATH }}
91+
working-directory: ./tofu/config/${{ inputs.config }}
8192
run: tofu init
8293
- name: Plan changes
83-
working-directory: ${{ env.CONFIG_PATH }}
94+
working-directory: ./tofu/config/${{ inputs.config }}
8495
run: tofu plan -concise -no-color -out tfplan > plan.txt
8596
- name: Display plan
86-
working-directory: ${{ env.CONFIG_PATH }}
97+
working-directory: ./tofu/config/${{ inputs.config }}
8798
run: tofu show -plan tfplan
8899
- name: Upload plan file
89100
uses: actions/upload-artifact@v4
90101
with:
91102
name: tfplan
92103
path: |
93-
${{ env.CONFIG_PATH }}/plan.txt
94-
${{ env.CONFIG_PATH }}/tfplan
104+
./tofu/config/${{ inputs.config }}/plan.txt
105+
./tofu/config/${{ inputs.config }}/tfplan
95106
retention-days: 5

0 commit comments

Comments
 (0)