Add build-args input

Extra NAME=value build args, passed to both the scanned and the pushed
build, for repos that bake more than VERSION into the image.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
thomas.gloorandClaude Opus 5.5 committed 2026-10-26 10:11:23 +01:00
1 parent af9b97e111
commit 2c16d55a07
2 files changed
+15 -4

No files matched your search

+14 -4
View File
@@ -18,6 +18,10 @@ on:
description: 'Path to the Dockerfile (default: <context>/Dockerfile)'
type: string
default: ''
build-args:
description: 'Extra build args, one NAME=value per line (VERSION is always passed)'
type: string
default: ''
no-cache:
description: 'Build without cache, e.g. for scheduled rebuilds that must pick up new packages'
type: boolean
@@ -78,9 +82,9 @@ 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. 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.
# log shows every finding at once. VERSION and the build-args input are
# passed 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
id: scan
env:
@@ -89,6 +93,7 @@ jobs:
FILE: ${{ inputs.file }}
SEVERITY: ${{ inputs.severity }}
VERSION: ${{ steps.meta.outputs.version }}
BUILD_ARGS: ${{ inputs.build-args }}
NO_CACHE: ${{ inputs.no-cache }}
TRIVY_SERVER: ${{ vars.TRIVY_SERVER || 'http://localhost:4954' }}
TRIVY_TOKEN: ${{ secrets.TRIVY_TOKEN }}
@@ -101,6 +106,10 @@ jobs:
else
cache_args=(--cache-from "type=registry,ref=$IMAGE:buildcache")
fi
build_args=(--build-arg "VERSION=$VERSION")
while IFS= read -r arg; do
if [ -n "$arg" ]; then build_args+=(--build-arg "$arg"); fi
done <<< "$BUILD_ARGS"
status=0
for platform in "${platforms[@]}"; do
@@ -109,7 +118,7 @@ jobs:
echo "::group::Build $platform"
docker buildx build --platform "$platform" --load --pull \
--file "$FILE" --tag "$tag" \
--build-arg "VERSION=$VERSION" \
"${build_args[@]}" \
"${cache_args[@]}" \
"$CONTEXT"
echo "::endgroup::"
@@ -146,6 +155,7 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.meta.outputs.version }}
${{ inputs.build-args }}
cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max
# Only runs if NTFY_URL is set (e.g. https://ntfy.example.com/<topic>).