@@ -3,8 +3,14 @@ run-name: Account-wide infra deployment to ${{ inputs.account }} of ${{ inputs.b
33
44# An action environment would need
55# name=acc-test
6- # envs_to_pull: "qa" "ref" "int" "perftest"
7- # aws_account_id: 123456789 - get this from tf vars or something maybe?
6+ # envs_to_pull: "qa" "ref" "int" "perftest" - use aws session assume.py - pull out
7+ # OR json format: ["qa", "ref", "int", "perftest"] - feels better
8+ # OR json obj lookup in repo-wide variable instead + same for below
9+ # aws_account_id: 123456789 - get this from tf vars or something maybe? - use get_account_name script
10+
11+ # MGMT_ROLE_ARN is in repo secrets, so not needed in env
12+
13+ # Looping through envs to pull certs
814
915on :
1016 workflow_dispatch :
@@ -28,6 +34,49 @@ permissions:
2834 actions : write
2935
3036jobs :
37+ # provide-cert-env-matrix:
38+ # runs-on: codebuild-nhsd-nrlf-ci-build-project-${{ github.run_id }}-${{ github.run_attempt }}
39+ # steps:
40+ # # here we create the json, we need the "id:" so we can use it in "outputs" bellow
41+ # - id: set-matrix
42+ # run: echo "::set-output name=matrix::$(vendor/bin/monorepo-builder packages-json --names)"
43+
44+ # # here, we save the result of this 1st phase to the "outputs"
45+ # outputs:
46+ # matrix: ${{ steps.set-matrix.outputs.matrix }}
47+
48+ pull-certs :
49+ name : Pull certs per env
50+ runs-on : codebuild-nhsd-nrlf-ci-build-project-${{ github.run_id }}-${{ github.run_attempt }}
51+ # env:
52+ # ENVS_TO_PULL: ${{ vars.envs_to_pull }}
53+ strategy :
54+ matrix :
55+ env_to_pull : ${{ fromJson(vars.envs_to_pull) }}
56+ steps :
57+ - name : Configure Management Credentials
58+ uses : aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1
59+ with :
60+ aws-region : eu-west-2
61+ role-to-assume : ${{ secrets.MGMT_ROLE_ARN }}
62+ role-session-name : github-actions-ci-${{ inputs.account }}-${{ github.run_id }}
63+
64+ - name : Retrieve Server Certificates
65+ env :
66+ # // TODO: needs to go in an environment or be looked up somehow envs_to_pull=("dev" "test" "preid")
67+ ENV_TO_PULL : ${{ matrix.env_to_pull }}
68+ run : |
69+ echo $ENV_TO_PULL
70+ make truststore-pull-server ENV=$ENV_TO_PULL
71+
72+ # Can I even do this for something sensitive? Maybe no
73+ - name : Save Cert Artifacts
74+ uses : actions/upload-artifact@v4
75+ with :
76+ name : cert-artifact-${{ matrix.env_to_pull }}
77+ path : |
78+ truststore/**/*.pem
79+
3180 # build:
3281 # name: Build - ${{ inputs.branch_name }}
3382 # runs-on: codebuild-nhsd-nrlf-ci-build-project-${{ github.run_id }}-${{ github.run_attempt }}
84133 terraform-plan :
85134 name : Terraform Plan - ${{ inputs.account }}
86135 # needs: [build]
136+ needs : [pull-certs]
87137 # environment: ${{ inputs.environment }}
88138 # environment: acc-${{ inputs.environment }} ??
89139 runs-on : codebuild-nhsd-nrlf-ci-build-project-${{ github.run_id }}-${{ github.run_attempt }}
@@ -106,6 +156,14 @@ jobs:
106156 role-to-assume : ${{ secrets.MGMT_ROLE_ARN }}
107157 role-session-name : github-actions-ci-${{ inputs.account }}-${{ github.run_id }}
108158
159+ - name : Download certs
160+ uses : actions/download-artifact@v5
161+ with :
162+ name : cert-artifacts-*
163+ path : truststore
164+
165+ # -------- OR --------
166+
109167 - name : Retrieve Server Certificates
110168 env :
111169 // TODO : needs to go in an environment or be looked up somehow envs_to_pull=("dev" "test" "preid")
@@ -298,35 +356,42 @@ jobs:
298356 # run: |
299357 # make ENV=$ENVIRONMENT test-smoke-public
300358
301- # Can we rollback changes if needed? Or just manually rerun pipeline for last working commit?
302- # rollback-stack:
303- # name: Rollback - ${{ inputs.environment }}
304- # needs: [post-release-verify]
305- # if: always() && ( needs.post-release-verify.result == 'failure' )
306- # runs-on: codebuild-nhsd-nrlf-ci-build-project-${{ github.run_id }}-${{ github.run_attempt }}
307- # environment: ${{ inputs.environment }}
308-
309- # steps:
310- # - name: Git clone - ${{ inputs.branch_name }}
311- # uses: actions/checkout@v4
312- # with:
313- # ref: ${{ inputs.branch_name }}
314-
315- # - name: Setup environment
316- # run: |
317- # echo "${HOME}/.asdf/bin" >> $GITHUB_PATH
318- # poetry install --no-root
319-
320- # - name: Configure Management Credentials
321- # uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a #v4.3.1
322- # with:
323- # aws-region: eu-west-2
324- # role-to-assume: ${{ secrets.MGMT_ROLE_ARN }}
325- # role-session-name: github-actions-ci-${{ inputs.environment }}-${{ github.run_id}}
326-
327- # - name: Deactivate Stack
328- # env:
329- # ENVIRONMENT: ${{ inputs.environment }}
330- # run: |
331- # inactive_stack_name=$(poetry run python ./scripts/get_env_config.py inactive-stack $ENVIRONMENT)
332- # poetry run python ./scripts/activate_stack.py ${inactive_stack_name} $ENVIRONMENT
359+ # Slack notif: starting deploy of account-wide infra <branch deets>
360+ # tf-plan: ensure output is visible in job output
361+
362+ # pre-apply: check current commit deployed in state
363+ # post-apply: update current deployed commit in state
364+ # no auto rollback
365+
366+ # Can we rollback changes if needed? Or just manually rerun pipeline for last working commit?
367+ # rollback-stack:
368+ # name: Rollback - ${{ inputs.environment }}
369+ # needs: [post-release-verify]
370+ # if: always() && ( needs.post-release-verify.result == 'failure' )
371+ # runs-on: codebuild-nhsd-nrlf-ci-build-project-${{ github.run_id }}-${{ github.run_attempt }}
372+ # environment: ${{ inputs.environment }}
373+
374+ # steps:
375+ # - name: Git clone - ${{ inputs.branch_name }}
376+ # uses: actions/checkout@v4
377+ # with:
378+ # ref: ${{ inputs.branch_name }}
379+
380+ # - name: Setup environment
381+ # run: |
382+ # echo "${HOME}/.asdf/bin" >> $GITHUB_PATH
383+ # poetry install --no-root
384+
385+ # - name: Configure Management Credentials
386+ # uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a #v4.3.1
387+ # with:
388+ # aws-region: eu-west-2
389+ # role-to-assume: ${{ secrets.MGMT_ROLE_ARN }}
390+ # role-session-name: github-actions-ci-${{ inputs.environment }}-${{ github.run_id}}
391+
392+ # - name: Deactivate Stack
393+ # env:
394+ # ENVIRONMENT: ${{ inputs.environment }}
395+ # run: |
396+ # inactive_stack_name=$(poetry run python ./scripts/get_env_config.py inactive-stack $ENVIRONMENT)
397+ # poetry run python ./scripts/activate_stack.py ${inactive_stack_name} $ENVIRONMENT
0 commit comments