@@ -13,11 +13,35 @@ permissions:
1313 actions : read # This is required for Plan comment
1414 id-token : write # This is required for requesting the JWT
1515 contents : write # This is required for SBOM action
16-
16+
1717jobs :
18+
19+ # Terraform apply of pre-core will only occur on a push (merge request completion)
20+ terraform_plan_apply_pre_core :
21+ if : github.ref == 'refs/heads/main'
22+ name : Terraform Plan/Apply (pre_core)
23+ runs-on : ubuntu-latest
24+ environment : development
25+ steps :
26+ - name : Checkout branch
27+ uses : actions/checkout@v5
28+
29+ - name : Apply pre_core
30+ uses : ./.github/actions/tf-plan-apply
31+ with :
32+ aws_assume_role : ${{ secrets.AWS_ASSUME_ROLE }}
33+ aws_region : ${{ vars.AWS_REGION }}
34+ backend_conf : " backend.conf"
35+ working_directory : " ./pre_core" # Use separate pre_core directory
36+ workspace : ${{ secrets.AWS_WORKSPACE }}
37+ tf_vars_file : ${{ vars.TF_VARS_FILE }}
38+
39+ # Will run when terraform_plan_apply_pre_core completes or is skipped
1840 terraform_plan_apply :
1941 name : Terraform Plan/Apply (ndr-dev)
2042 runs-on : ubuntu-latest
43+ needs : terraform_plan_apply_pre_core
44+ if : always() && (needs.terraform_plan_apply_pre_core.result == 'skipped' || needs.terraform_plan_apply_pre_core.result == 'success')
2145 environment : development
2246 steps :
2347 - name : Checkout
7397 echo "::add-mask::$cert_block"
7498 fi
7599 done || echo "No certificate blocks found to mask."
76-
100+
77101 # Mask sensitive URLs in the Terraform Plan output
78102 grep -Eo 'https://[a-zA-Z0-9.-]+\.execute-api\.[a-zA-Z0-9.-]+\.amazonaws\.com/[a-zA-Z0-9/._-]*' tfplan.txt | while read -r api_url; do
79103 if [ -n "$api_url" ]; then
@@ -153,7 +177,7 @@ jobs:
153177
154178 // 2. Prepare format of the comment
155179 const output = `### Report for environment: ndr-dev
156-
180+
157181 #### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
158182 <details><summary>Initialization Output</summary>
159183
@@ -191,7 +215,7 @@ jobs:
191215 body: output
192216 })
193217 }
194-
218+
195219 github.rest.issues.createComment({
196220 issue_number: context.issue.number,
197221 owner: context.repo.owner,
0 commit comments