Skip to content

Commit d5f1696

Browse files
authored
ci(publish): unify image scanning across published images (#4306)
## What Run the shared Trivy image scan on every published image through a single reusable workflow. ## Changes - Generalise the image-scan workflow (`trivy-image-webapp.yml` -> `trivy-image.yml`) - it was already parameterised by `image-ref`; only the run-summary label was image-specific. - `publish-worker-v4.yml`: expose `version` + `image_repo` as workflow outputs (single-entry matrix, so unambiguous). - `publish.yml`: run the shared scan from each publish job (`scan-webapp`, `scan-supervisor`). Report-only (writes a table to the run summary), OS packages only (`vuln-type: os` - library deps stay with Dependabot), never blocks the publish.
1 parent a7c734c commit d5f1696

3 files changed

Lines changed: 30 additions & 8 deletions

File tree

.github/workflows/publish-worker-v4.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ on:
1313
type: string
1414
required: false
1515
default: ""
16+
outputs:
17+
version:
18+
description: The published image tag
19+
value: ${{ jobs.build.outputs.version }}
20+
image_repo:
21+
description: The image repository the build was published to (without tag)
22+
value: ${{ jobs.build.outputs.image_repo }}
1623
push:
1724
tags:
1825
- "re2-test-*"
@@ -38,6 +45,11 @@ jobs:
3845
matrix:
3946
package: [supervisor]
4047
runs-on: warp-ubuntu-latest-x64-2x
48+
# Single-entry matrix, so these job outputs are unambiguous (consumed by the
49+
# scan-supervisor job in publish.yml).
50+
outputs:
51+
version: ${{ steps.get_tag.outputs.tag }}
52+
image_repo: ${{ steps.set_tags.outputs.image_repo }}
4153
env:
4254
DOCKER_BUILDKIT: "1"
4355
steps:
@@ -81,6 +93,7 @@ jobs:
8193
fi
8294
8395
echo "image_tags=${image_tags}" >> "$GITHUB_OUTPUT"
96+
echo "image_repo=${ref_without_tag}" >> "$GITHUB_OUTPUT"
8497
env:
8598
IMAGE_REGISTRY: ${{ inputs.image_registry || vars.IMAGE_REGISTRY || format('ghcr.io/{0}', github.repository_owner) }}
8699
STEPS_GET_REPOSITORY_OUTPUTS_REPO: ${{ steps.get_repository.outputs.repo }}

.github/workflows/publish.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,19 @@ jobs:
9797
permissions:
9898
contents: read
9999
packages: read # pull the just-published image from GHCR
100-
uses: ./.github/workflows/trivy-image-webapp.yml
100+
uses: ./.github/workflows/trivy-image.yml
101101
with:
102102
image-ref: ${{ needs.publish-webapp.outputs.image_repo }}:${{ needs.publish-webapp.outputs.version }}
103103

104+
scan-supervisor:
105+
needs: [publish-worker-v4]
106+
permissions:
107+
contents: read
108+
packages: read # pull the just-published image from GHCR
109+
uses: ./.github/workflows/trivy-image.yml
110+
with:
111+
image-ref: ${{ needs.publish-worker-v4.outputs.image_repo }}:${{ needs.publish-worker-v4.outputs.version }}
112+
104113
# Announce the freshly published mutable `main` webapp image to subscriber
105114
# repos via repository_dispatch, handing them a digest-pinned ref to build or
106115
# deploy from. The repo, ref prefix, and dispatch target all default to the
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
name: Trivy Image Scan (webapp)
1+
name: Trivy Image Scan
22

3-
# OS-level CVE scan of a published webapp image. Called by the publish pipeline
4-
# (publish.yml) to scan each build right after it's pushed to GHCR — so every
3+
# OS-level CVE scan of a published image. Called by the publish pipeline
4+
# (publish.yml) to scan each image right after it's pushed to GHCR — so every
55
# main build and every release is scanned, not rebuilt. Also runnable ad-hoc
66
# via workflow_dispatch against any image ref.
77
#
@@ -27,7 +27,7 @@ on:
2727
permissions: {}
2828

2929
concurrency:
30-
group: trivy-image-webapp-${{ inputs.image-ref }}
30+
group: trivy-image-${{ inputs.image-ref }}
3131
cancel-in-progress: true
3232

3333
jobs:
@@ -59,17 +59,17 @@ jobs:
5959
ignore-unfixed: true
6060
severity: HIGH,CRITICAL
6161
format: table
62-
output: trivy-image-webapp.txt
62+
output: trivy-image.txt
6363

6464
- name: Job summary
6565
if: always()
6666
env:
6767
IMAGE_REF: ${{ inputs.image-ref }}
6868
run: |
6969
{
70-
echo "## Trivy Image Scan (webapp) — \`${IMAGE_REF}\`"
70+
echo "## Trivy Image Scan — \`${IMAGE_REF}\`"
7171
echo '```'
7272
# GitHub step summary is capped at 1 MiB; truncate large reports.
73-
head -c 900000 trivy-image-webapp.txt 2>/dev/null || echo "(no report produced)"
73+
head -c 900000 trivy-image.txt 2>/dev/null || echo "(no report produced)"
7474
echo '```'
7575
} >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)