3232 image : ghcr.io/nhsdigital/eps-devcontainers/${{ inputs.runtime_docker_image }}
3333 options : --user 1001:1001
3434 steps :
35+ - &init_tool_versions
36+ name : copy .tool-versions
37+ run : |
38+ cp /home/vscode/.tool-versions "$HOME/.tool-versions"
39+
3540 - &checkout
3641 name : Checkout code
3742 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
5661
5762 - name : make install
5863 run : |
59- cp /home/vscode/.tool-versions "$HOME/.tool-versions"
60- echo "Running id"
61- id
62- echo "Running pwd"
63- pwd
64- echo "Running env"
65- env
66- echo "Running make install"
6764 make install
68- echo "These are env vars"
69- echo "VAR1 is $VAR1"
70- echo "VAR2 is $VAR2"
71- env :
72- VAR1 : value1
73- VAR2 : value2
7465 - name : Run secrets scan
7566 run : |
7667 make secret-scan
@@ -212,15 +203,15 @@ jobs:
212203 SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
213204
214205 get_docker_images_to_scan :
206+ runs-on : ubuntu-22.04
207+ container :
208+ image : ghcr.io/nhsdigital/eps-devcontainers/${{ inputs.runtime_docker_image }}
209+ options : --user 1001:1001
215210 outputs :
216211 docker_images : ${{ steps.normalized_docker_images.outputs.images }}
217- runs-on : ubuntu-22.04
218212 steps :
219- - name : Checkout code
220- uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
221- with :
222- ref : ${{ env.BRANCH_NAME }}
223- fetch-depth : 0
213+ - *init_tool_versions
214+ - *checkout
224215 - name : Determine docker images to scan
225216 id : normalized_docker_images
226217 env :
@@ -279,56 +270,31 @@ jobs:
279270
280271 docker_vulnerability_scan :
281272 runs-on : ubuntu-22.04
273+ container :
274+ image : ghcr.io/nhsdigital/eps-devcontainers/${{ inputs.runtime_docker_image }}
275+ options : --user 1001:1001
282276 needs : get_docker_images_to_scan
283277 if : ${{ inputs.run_docker_scan == true }}
284278 strategy :
285279 matrix :
286280 docker_image : ${{ fromJson(needs.get_docker_images_to_scan.outputs.docker_images) }}
287281 steps :
288- - name : Checkout code
289- uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
290- with :
291- ref : ${{ env.BRANCH_NAME }}
292- fetch-depth : 0
293- - name : Setting up .npmrc
294- env :
295- NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
296- run : |
297- echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> ~/.npmrc
298- echo "@nhsdigital:registry=https://npm.pkg.github.com" >> ~/.npmrc
299-
300- - name : Cache npm dependencies
301- uses : actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb
302- with :
303- path : ./node_modules
304- key : ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
305- restore-keys : |
306- ${{ runner.os }}-node-
282+ - *init_tool_versions
283+ - *checkout
284+ - *setup_npmrc
285+ - *cache_npm
307286
308287 - name : make install
309- uses : anthony-nhs/docker-run-action-fork@80b8bf1eaca8275e1c2b848cf7ea5fabb2443d78
310- with :
311- workspace_folder : ${{ github.workspace }}
312- image : ${{ inputs.runtime_docker_image }}
313- run : |
314- make install
288+ run : |
289+ make install
315290
316291 - name : Build docker images
317- if : ${{ inputs.run_docker_scan == true }}
318- uses : anthony-nhs/docker-run-action-fork@80b8bf1eaca8275e1c2b848cf7ea5fabb2443d78
319- with :
320- workspace_folder : ${{ github.workspace }}
321- image : ${{ inputs.runtime_docker_image }}
322- run : |
323- make docker-build
292+ run : |
293+ make docker-build
324294
325295 - name : Check docker vulnerabilities
326- uses : anthony-nhs/docker-run-action-fork@80b8bf1eaca8275e1c2b848cf7ea5fabb2443d78
327- with :
328- workspace_folder : ${{ github.workspace }}
329- image : ${{ inputs.runtime_docker_image }}
330- run : |
331- make trivy-scan-docker
296+ run : |
297+ make trivy-scan-docker
332298 env :
333299 DOCKER_IMAGE : ${{ matrix.docker_image }}
334300
@@ -343,7 +309,10 @@ jobs:
343309 IaC-validation :
344310 runs-on : ubuntu-22.04
345311 steps :
312+ - *init_tool_versions
346313 - *checkout
314+ - *setup_npmrc
315+ - *cache_npm
347316
348317 - name : Check for SAM templates
349318 id : check_sam_templates
@@ -392,58 +361,31 @@ jobs:
392361
393362 - name : Run cfn-lint
394363 if : steps.check_sam_templates.outputs.sam_exists == 'true' || steps.check_cf_templates.outputs.cf_exists == 'true'
395- uses : anthony-nhs/docker-run-action-fork@80b8bf1eaca8275e1c2b848cf7ea5fabb2443d78
396- with :
397- workspace_folder : ${{ github.workspace }}
398- image : ${{ inputs.runtime_docker_image }}
399- run : |
400- make cfn-lint
401-
402- - *cache_npm
403- - *setup_npmrc
364+ run : |
365+ make cfn-lint
404366
405367 - name : make install NodeJS
406368 if : steps.check_cdk.outputs.cdk_exists == 'true'
407- uses : anthony-nhs/docker-run-action-fork@80b8bf1eaca8275e1c2b848cf7ea5fabb2443d78
408- with :
409- workspace_folder : ${{ github.workspace }}
410- image : ${{ inputs.runtime_docker_image }}
411- run : |
412- make install-node compile
369+ run : |
370+ make install-node compile
413371
414372 - name : Run cdk-synth
415373 if : steps.check_cdk.outputs.cdk_exists == 'true'
416- uses : anthony-nhs/docker-run-action-fork@80b8bf1eaca8275e1c2b848cf7ea5fabb2443d78
417- with :
418- workspace_folder : ${{ github.workspace }}
419- image : ${{ inputs.runtime_docker_image }}
420- run : |
421- make cdk-synth
374+ run : |
375+ make cdk-synth
422376
423377 - name : Run cfn-guard script for sam templates
424- uses : anthony-nhs/docker-run-action-fork@80b8bf1eaca8275e1c2b848cf7ea5fabb2443d78
425- with :
426- workspace_folder : ${{ github.workspace }}
427- image : ${{ inputs.runtime_docker_image }}
428- run : |
429- make cfn-guard-sam-templates
378+ run : |
379+ make cfn-guard-sam-templates
430380
431381 - name : Run cfn-guard script for cloudformation templates
432382 if : steps.check_cf_templates.outputs.cf_exists == 'true'
433- uses : anthony-nhs/docker-run-action-fork@80b8bf1eaca8275e1c2b848cf7ea5fabb2443d78
434- with :
435- workspace_folder : ${{ github.workspace }}
436- image : ${{ inputs.runtime_docker_image }}
437- run : |
438- make cfn-guard-cloudformation
383+ run : |
384+ make cfn-guard-cloudformation
439385 - name : Run cfn-guard script for cdk templates
440386 if : steps.check_cdk.outputs.cdk_exists == 'true'
441- uses : anthony-nhs/docker-run-action-fork@80b8bf1eaca8275e1c2b848cf7ea5fabb2443d78
442- with :
443- workspace_folder : ${{ github.workspace }}
444- image : ${{ inputs.runtime_docker_image }}
445- run : |
446- make cfn-guard-cdk
387+ run : |
388+ make cfn-guard-cdk
447389
448390 - name : Download terraform plans
449391 uses : actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
@@ -466,12 +408,8 @@ jobs:
466408
467409 - name : Run cfn-guard script for terraform plans
468410 if : steps.check_terraform_plans.outputs.terraform_plans_exist == 'true'
469- uses : anthony-nhs/docker-run-action-fork@80b8bf1eaca8275e1c2b848cf7ea5fabb2443d78
470- with :
471- workspace_folder : ${{ github.workspace }}
472- image : ${{ inputs.runtime_docker_image }}
473- run : |
474- make cfn-guard-terraform
411+ run : |
412+ make cfn-guard-terraform
475413
476414 - name : Show cfn-guard output
477415 if : failure()
0 commit comments