Skip to content

Commit bc1c4c1

Browse files
authored
[NDR-166] Add a base terraform build to a sandbox (#347)
* add a base terraform build to a sandbox * set plan ids * Add init to branch section. * Set base build plan name * Set workspace * Test * PR comments
1 parent 5ff7826 commit bc1c4c1

File tree

1 file changed

+43
-16
lines changed

1 file changed

+43
-16
lines changed

.github/workflows/terraform-deploy-feature-to-sandbox.yml

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
# .github/workflows/terraform-dev
2-
name: 'Deploy Feature Branch to Sandbox'
2+
name: "Deploy Feature Branch to Sandbox"
33

44
on:
55
workflow_dispatch:
66
inputs:
77
buildBranch:
8-
description: 'Feature branch to push to sandbox.'
8+
description: "Feature branch to push to sandbox."
99
required: true
10-
type: 'string'
10+
type: "string"
1111
sandboxWorkspace:
12-
description: 'Which Sandbox to push to.'
12+
description: "Which Sandbox to push to."
1313
required: true
14-
type: 'string'
14+
type: "string"
1515
environment:
16-
default: 'development'
17-
description: 'Which environment should this run against'
16+
default: "development"
17+
description: "Which environment should this run against"
1818
required: true
19-
type: 'string'
19+
type: "string"
2020

2121
permissions:
2222
pull-requests: write
@@ -29,11 +29,10 @@ jobs:
2929
environment: ${{ github.event.inputs.environment }}
3030

3131
steps:
32-
# Checkout the repository to the GitHub Actions runner
33-
- name: Checkout
32+
- name: Checkout Base
3433
uses: actions/checkout@v4
3534
with:
36-
ref: ${{ github.event.inputs.buildBranch}}
35+
ref: main
3736

3837
- name: Configure AWS Credentials
3938
uses: aws-actions/configure-aws-credentials@v4
@@ -53,23 +52,51 @@ jobs:
5352
terraform_version: 1.11.4
5453
terraform_wrapper: false
5554

56-
- name: Terraform Init
57-
id: init
55+
- name: Terraform Init Base
56+
id: base_init
5857
run: terraform init -backend-config=backend.conf
5958
working-directory: ./infrastructure
6059
shell: bash
6160

62-
- name: Terraform Set Workspace
63-
id: workspace
61+
- name: Terraform Set Workspace Base
62+
id: base_workspace
6463
run: terraform workspace select -or-create ${{ github.event.inputs.sandboxWorkspace}}
6564
working-directory: ./infrastructure
6665
shell: bash
6766

68-
# Checks that all Terraform configuration files adhere to a canonical format
67+
- name: Terraform Plan Base
68+
id: base_plan
69+
run: |
70+
terraform plan -input=false -no-color -var-file="${{vars.TF_VARS_FILE}}" -out tf-base.plan
71+
working-directory: ./infrastructure
72+
shell: bash
73+
74+
- name: Terraform Apply Base
75+
run: terraform apply -auto-approve -input=false tf-base.plan
76+
working-directory: ./infrastructure
77+
78+
- name: Checkout Branch
79+
uses: actions/checkout@v4
80+
with:
81+
ref: ${{ github.event.inputs.buildBranch}}
82+
83+
# Checks that all Terraform configuration files adhere to a canonical format.
6984
- name: Terraform Format
7085
run: terraform fmt -check
7186
working-directory: ./infrastructure
7287

88+
- name: Terraform Init
89+
id: init
90+
run: terraform init -backend-config=backend.conf
91+
working-directory: ./infrastructure
92+
shell: bash
93+
94+
- name: Terraform Set Workspace
95+
id: workspace
96+
run: terraform workspace select ${{ github.event.inputs.sandboxWorkspace}}
97+
working-directory: ./infrastructure
98+
shell: bash
99+
73100
- name: Terraform Plan
74101
id: plan
75102
run: |

0 commit comments

Comments
 (0)