@@ -607,3 +607,73 @@ jobs:
607607 - name : Setup tmate debug session
608608 uses : mxschmitt/action-tmate@v3
609609 if : env.RUN_TMATE
610+ generate-sbom :
611+ # Generate an SBOM for the Docker image and, if there is a
612+ # release, upload it as an asset to the release.
613+ #
614+ # This job is located in this workflow as opposed to a separate
615+ # release workflow because it can only run after the
616+ # build-push-all job. Putting it in a separate workflow would
617+ # require us to introduce a dependency of the release workflow on
618+ # this one.
619+ if : github.event_name != 'pull_request'
620+ name : Generate and upload SBOM
621+ needs :
622+ - diagnostics
623+ - repo-metadata
624+ - build-push-all
625+ permissions :
626+ # Allows us to read the SBOM artifact
627+ actions : read
628+ artifact-metadata : write
629+ attestations : write
630+ # Allows us to add the SBOM to the release
631+ contents : write
632+ # Allows the workflow to mint the OIDC token necessary to
633+ # request a Sigstore signing certificate.
634+ id-token : write
635+ runs-on : ubuntu-latest
636+ strategy :
637+ fail-fast : false
638+ matrix :
639+ sbom-format :
640+ - cyclonedx-json
641+ - spdx-json
642+ steps :
643+ - name : Apply standard cisagov job preamble
644+ uses : cisagov/action-job-preamble@v1
645+ with :
646+ # This functionality is poorly implemented and has been
647+ # causing problems due to the MITM implementation hogging or
648+ # leaking memory. As a result we disable it by default. If
649+ # you want to temporarily enable it, simply set
650+ # monitor_permissions equal to "true".
651+ #
652+ # TODO: Re-enable this functionality when practical. See
653+ # cisagov/skeleton-docker#224 for more details.
654+ monitor_permissions : " false"
655+ # Use a variable to specify the permissions monitoring
656+ # configuration. By default this will yield the
657+ # configuration stored in the cisagov organization-level
658+ # variable, but if you want to use a different configuration
659+ # then simply:
660+ # 1. Create a repository-level variable with the name
661+ # ACTIONS_PERMISSIONS_CONFIG.
662+ # 2. Set this new variable's value to the configuration you
663+ # want to use for this repository.
664+ #
665+ # Note in particular that changing the permissions
666+ # monitoring configuration *does not* require you to modify
667+ # this workflow.
668+ permissions_monitoring_config : ${{ vars.ACTIONS_PERMISSIONS_CONFIG }}
669+ - name : Gemerate SBOM
670+ uses : anchore/sbom-action@v0
671+ with :
672+ artifact_name : sbom.${{ matrix.sbom-format }}
673+ format : ${{ matrix.sbom-format }}
674+ image : ${{ needs.repo-metadata.outputs.image-name }}:${{ github.ref }}
675+ output_name : sbom.${{ matrix.sbom-format }}
676+ - name : Attest build provenance for the SBOM
677+ uses : actions/attest-build-provenance@v3
678+ with :
679+ subject-path : sbom.${{ matrix.sbom-format }}
0 commit comments