Skip to content

Commit 71048c5

Browse files
committed
fix(ci): fix Trivy scan failures in docker-publish workflow
- Set TRIVY_PLATFORM to match matrix arch so remote pull resolves correctly - Run Trivy/cosign with `if: always()` so cache 502s don't block scanning - Guard SARIF upload with file existence check to prevent cascade errors
1 parent 773965a commit 71048c5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

.github/workflows/docker-publish.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ jobs:
167167
cache-to: type=gha,mode=max,scope=${{ matrix.service }}-${{ matrix.platform.arch }}
168168

169169
- name: Scan image for vulnerabilities
170+
if: always() && steps.build.outcome != 'cancelled'
171+
env:
172+
TRIVY_PLATFORM: ${{ matrix.platform.os }}
170173
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # 0.35.0
171174
with:
172175
image-ref: ${{ env.IMAGE_PREFIX }}-${{ matrix.service }}:${{ steps.version.outputs.tag }}-${{ matrix.platform.arch }}
@@ -177,14 +180,16 @@ jobs:
177180

178181
- name: Upload scan results to GitHub Security
179182
uses: github/codeql-action/upload-sarif@b25d0ebf40e5b63ee81e1bd6e5d2a12b7c2aeb61 # v4
180-
if: always()
183+
if: always() && hashFiles('trivy-results.sarif') != ''
181184
with:
182185
sarif_file: trivy-results.sarif
183186

184187
- name: Install cosign
188+
if: always() && steps.build.outcome != 'cancelled'
185189
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4
186190

187191
- name: Sign image
192+
if: always() && steps.build.outcome != 'cancelled'
188193
run: cosign sign --yes ${{ env.IMAGE_PREFIX }}-${{ matrix.service }}:${{ steps.version.outputs.tag }}-${{ matrix.platform.arch }}
189194

190195
manifest:

0 commit comments

Comments
 (0)