Pass VERSION build arg, limit build parallelism, update actions

- Pass the image version as build arg VERSION to both the scan and push
  builds, so the scanned image matches the pushed one
- Limit BuildKit to 8 parallel steps (as mqtt-influx-bridge did)
- Update actions to checkout@v7, setup-qemu@v4, setup-buildx@v4,
  login@v4, metadata@v6, build-push@v7

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
thomas.gloorandClaude Opus 5.5 committed 2026-10-18 20:30:25 +02:00
1 parent 8228a19251
commit 4b2129b544
2 files changed
+20 -8

No files matched your search

+17 -8
View File
@@ -36,7 +36,7 @@ jobs:
runs-on: ${{ inputs.runs-on }}
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v7
# Docker image names must be lowercase; Gitea owner/repo names may not be.
- name: Set image name
@@ -44,13 +44,17 @@ jobs:
- name: Set up QEMU
if: contains(inputs.platforms, 'arm')
uses: docker/setup-qemu-action@v3
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v4
with:
buildkitd-config-inline: |
[worker.oci]
max-parallelism = 8
- name: Log in to Gitea container registry
uses: docker/login-action@v3
uses: docker/login-action@v4
with:
registry: git.hin-fort.ch
username: ${{ gitea.actor }}
@@ -58,7 +62,7 @@ jobs:
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
uses: docker/metadata-action@v6
with:
images: ${{ env.IMAGE }}
tags: |
@@ -70,13 +74,16 @@ jobs:
# Each platform is built into the local Docker daemon on its own (a
# multi-platform image can't be loaded), scanned against the Trivy server,
# and removed again. All platforms are scanned even if one fails, so the
# log shows every finding at once.
# log shows every finding at once. VERSION is passed as a build arg (as in
# the push step) so the scanned image matches the pushed one; Dockerfiles
# that don't declare ARG VERSION ignore it.
- name: Build and scan with Trivy
env:
PLATFORMS: ${{ inputs.platforms }}
CONTEXT: ${{ inputs.context }}
FILE: ${{ inputs.file }}
SEVERITY: ${{ inputs.severity }}
VERSION: ${{ steps.meta.outputs.version }}
TRIVY_SERVER: ${{ vars.TRIVY_SERVER || 'http://localhost:4954' }}
TRIVY_TOKEN: ${{ secrets.TRIVY_TOKEN }}
run: |
@@ -90,7 +97,7 @@ jobs:
echo "::group::Build $platform"
docker buildx build --platform "$platform" --load --pull \
--file "$FILE" --tag "$tag" \
--file "$FILE" --tag "$tag" --build-arg "VERSION=$VERSION" \
--cache-from "type=registry,ref=$IMAGE:buildcache" \
"$CONTEXT"
echo "::endgroup::"
@@ -115,7 +122,7 @@ jobs:
# Reuses the layers built above, so this mostly assembles and uploads.
# pull: false keeps the base images identical to the ones just scanned.
- name: Build and push
uses: docker/build-push-action@v5
uses: docker/build-push-action@v7
with:
context: ${{ inputs.context }}
file: ${{ inputs.file }}
@@ -124,5 +131,7 @@ jobs:
pull: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.meta.outputs.version }}
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max
+3
View File
@@ -41,6 +41,9 @@ For x64 and arm64 (Raspberry Pi), add:
| `severity` | `CRITICAL,HIGH` | Severities that fail the build. Vulnerabilities without a fixed version never fail it. |
| `runs-on` | `linux-amd64` | Runner label. |
The image version from the tag/branch (e.g. `1.4.0`, `main`) is passed as
build arg `VERSION`; declare `ARG VERSION` in the Dockerfile to use it.
### Required secrets
Set these on the repo's organisation (or on the repo):