@@ -353,7 +353,7 @@ jobs:
353353 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
354354 SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
355355
356- docker_image_build :
356+ get_docker_images_to_scan :
357357 outputs :
358358 docker_images : ${{ steps.normalized_docker_images.outputs.images }}
359359 runs-on : ubuntu-22.04
@@ -363,58 +363,6 @@ jobs:
363363 with :
364364 ref : ${{ env.BRANCH_NAME }}
365365 fetch-depth : 0
366- # using git commit sha for version of action to ensure we have stable version
367- - name : Install asdf
368- uses : asdf-vm/actions/setup@b7bcd026f18772e44fe1026d729e1611cc435d47
369- with :
370- asdf_version : ${{ inputs.asdfVersion }}
371-
372- - name : Cache asdf
373- uses : actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb
374- with :
375- path : |
376- ~/.asdf
377- key : ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}-${{ inputs.asdfVersion }}
378- restore-keys : |
379- ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}-${{ inputs.asdfVersion }}
380-
381- - name : Install asdf dependencies in .tool-versions
382- uses : asdf-vm/actions/install@b7bcd026f18772e44fe1026d729e1611cc435d47
383- with :
384- asdf_version : ${{ inputs.asdfVersion }}
385- env :
386- PYTHON_CONFIGURE_OPTS : --enable-shared
387-
388- - name : Reinstall poetry
389- if : ${{ inputs.reinstall_poetry }}
390- run : |
391- poetry_tool_version=$(cat .tool-versions | grep poetry)
392- poetry_version=${poetry_tool_version//"poetry "}
393- asdf uninstall poetry "$poetry_version"
394- asdf install poetry
395-
396- - name : Setting up .npmrc
397- env :
398- NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
399- run : |
400- echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> ~/.npmrc
401- echo "@nhsdigital:registry=https://npm.pkg.github.com" >> ~/.npmrc
402-
403- - name : Cache npm dependencies
404- uses : actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb
405- with :
406- path : ./node_modules
407- key : ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
408- restore-keys : |
409- ${{ runner.os }}-node-
410-
411- - name : make install
412- run : |
413- make install
414- - name : Build docker images
415- if : ${{ inputs.run_docker_scan == true }}
416- run : |
417- make docker-build
418366 - name : Determine docker images to scan
419367 id : normalized_docker_images
420368 run : |
@@ -472,24 +420,76 @@ jobs:
472420
473421 docker_vulnerability_scan :
474422 runs-on : ubuntu-22.04
475- needs : docker_image_build
423+ needs : get_docker_images_to_scan
476424 if : ${{ inputs.run_docker_scan == true }}
477425 strategy :
478426 matrix :
479- docker_image : ${{ fromJson(needs.docker_image_build .outputs.docker_images) }}
427+ docker_image : ${{ fromJson(needs.get_docker_images_to_scan .outputs.docker_images) }}
480428 steps :
481429 - name : Checkout code
482430 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
483431 with :
484432 ref : ${{ env.BRANCH_NAME }}
485433 fetch-depth : 0
434+ # using git commit sha for version of action to ensure we have stable version
435+ - name : Install asdf
436+ uses : asdf-vm/actions/setup@b7bcd026f18772e44fe1026d729e1611cc435d47
437+ with :
438+ asdf_version : ${{ inputs.asdfVersion }}
439+
440+ - name : Cache asdf
441+ uses : actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb
442+ with :
443+ path : |
444+ ~/.asdf
445+ key : ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}-${{ inputs.asdfVersion }}
446+ restore-keys : |
447+ ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}-${{ inputs.asdfVersion }}
448+
449+ - name : Install asdf dependencies in .tool-versions
450+ uses : asdf-vm/actions/install@b7bcd026f18772e44fe1026d729e1611cc435d47
451+ with :
452+ asdf_version : ${{ inputs.asdfVersion }}
453+ env :
454+ PYTHON_CONFIGURE_OPTS : --enable-shared
455+
456+ - name : Reinstall poetry
457+ if : ${{ inputs.reinstall_poetry }}
458+ run : |
459+ poetry_tool_version=$(cat .tool-versions | grep poetry)
460+ poetry_version=${poetry_tool_version//"poetry "}
461+ asdf uninstall poetry "$poetry_version"
462+ asdf install poetry
463+
464+ - name : Setting up .npmrc
465+ env :
466+ NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
467+ run : |
468+ echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> ~/.npmrc
469+ echo "@nhsdigital:registry=https://npm.pkg.github.com" >> ~/.npmrc
470+
471+ - name : Cache npm dependencies
472+ uses : actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb
473+ with :
474+ path : ./node_modules
475+ key : ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
476+ restore-keys : |
477+ ${{ runner.os }}-node-
478+
479+ - name : make install
480+ run : |
481+ make install
486482
487483 - name : Prepare trivy config
488484 run : |
489485 cat <<'EOF' > trivy.yaml
490486 pkg:
491487 include-dev-deps: true
492488 EOF
489+ - name : Build docker images
490+ if : ${{ inputs.run_docker_scan == true }}
491+ run : |
492+ make docker-build
493493
494494 - name : Check docker vulnerabilities
495495 uses : aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8
0 commit comments