|
41 | 41 | outputs:
|
42 | 42 | container-tag: ${{ steps.publish-container.outputs.container-tag }}
|
43 | 43 |
|
| 44 | + permissions: |
| 45 | + attestations: write |
| 46 | + contents: read |
| 47 | + id-token: write |
| 48 | + |
44 | 49 | strategy:
|
45 | 50 | fail-fast: false
|
46 | 51 | matrix:
|
@@ -107,17 +112,49 @@ jobs:
|
107 | 112 |
|
108 | 113 | - name: Publish container
|
109 | 114 | id: publish-container
|
110 |
| - if: ${{ runner.os == 'Linux' }} |
| 115 | + if: runner.os == 'Linux' |
111 | 116 | shell: pwsh
|
112 | 117 | env:
|
113 | 118 | ContainerRegistry: ${{ env.PUBLISH_CONTAINER == 'true' && env.CONTAINER_REGISTRY || '' }}
|
114 | 119 | run: |
|
115 | 120 | dotnet publish ./src/API --arch x64 --os linux -p:PublishProfile=DefaultContainer
|
116 | 121 | if (-Not [string]::IsNullOrWhiteSpace(${env:CONTAINER_REGISTRY})) {
|
117 |
| - $containerTag = "${env:CONTAINER_REGISTRY}/${env:GITHUB_REPOSITORY}:github-${env:GITHUB_RUN_NUMBER}".ToLowerInvariant() |
| 122 | + $containerImage = "${env:CONTAINER_REGISTRY}/${env:GITHUB_REPOSITORY}".ToLowerInvariant() |
| 123 | + $containerTag = "${containerImage}:github-${env:GITHUB_RUN_NUMBER}".ToLowerInvariant() |
| 124 | + "container-image=${containerImage}" >> "${env:GITHUB_OUTPUT}" |
118 | 125 | "container-tag=${containerTag}" >> "${env:GITHUB_OUTPUT}"
|
119 | 126 | }
|
120 | 127 |
|
| 128 | + - name: Generate SBOM for binaries |
| 129 | + uses: anchore/sbom-action@v0 |
| 130 | + with: |
| 131 | + path: ./artifacts/publish |
| 132 | + output-file: ./artifacts/sbom-publish.json |
| 133 | + |
| 134 | + - name: Generate SBOM for container |
| 135 | + uses: anchore/sbom-action@v0 |
| 136 | + if: env.PUBLISH_CONTAINER == 'true' && steps.publish-container.outputs.container-digest != '' |
| 137 | + with: |
| 138 | + image: ${{ steps.publish-container.outputs.container-tag }} |
| 139 | + output-file: ./artifacts/sbom-container.json |
| 140 | + |
| 141 | + - name: Attest container image |
| 142 | + uses: actions/attest-build-provenance@v1 |
| 143 | + if: env.PUBLISH_CONTAINER == 'true' && steps.publish-container.outputs.container-digest != '' |
| 144 | + with: |
| 145 | + push-to-registry: true |
| 146 | + subject-digest: ${{ steps.publish-container.outputs.container-digest }} |
| 147 | + subject-name: ${{ steps.publish-container.outputs.container-image }} |
| 148 | + |
| 149 | + - name: Attest SBOM for container |
| 150 | + uses: actions/attest-sbom@v1 |
| 151 | + if: env.PUBLISH_CONTAINER == 'true' && steps.publish-container.outputs.container-digest != '' |
| 152 | + with: |
| 153 | + push-to-registry: true |
| 154 | + sbom-path: ./artifacts/sbom-container.json |
| 155 | + subject-digest: ${{ steps.publish-container.outputs.container-digest }} |
| 156 | + subject-name: ${{ steps.publish-container.outputs.container-image }} |
| 157 | + |
121 | 158 | deploy:
|
122 | 159 | if: github.event.repository.fork == false && github.ref_name == github.event.repository.default_branch
|
123 | 160 | name: deploy-production
|
|
0 commit comments