Add no-cache input; push step builds from local cache only

- no-cache input for scheduled rebuilds that must pick up new packages
- The push step no longer reads the registry cache, only the layers the
  scan step just built, so the pushed image is the scanned one even on
  no-cache runs
- Put --build-arg back on its own line

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:34:56 +02:00
1 parent 4b2129b544
commit 71fc972c77
2 files changed
+17 -5

No files matched your search

+16 -5
View File
@@ -18,6 +18,10 @@ on:
description: 'Path to the Dockerfile (default: <context>/Dockerfile)'
type: string
default: ''
no-cache:
description: 'Build without cache, e.g. for scheduled rebuilds that must pick up new packages'
type: boolean
default: false
severity:
description: 'Trivy severities that fail the build'
type: string
@@ -84,12 +88,18 @@ jobs:
FILE: ${{ inputs.file }}
SEVERITY: ${{ inputs.severity }}
VERSION: ${{ steps.meta.outputs.version }}
NO_CACHE: ${{ inputs.no-cache }}
TRIVY_SERVER: ${{ vars.TRIVY_SERVER || 'http://localhost:4954' }}
TRIVY_TOKEN: ${{ secrets.TRIVY_TOKEN }}
run: |
set -euo pipefail
FILE="${FILE:-$CONTEXT/Dockerfile}"
IFS=',' read -ra platforms <<< "$PLATFORMS"
if [ "$NO_CACHE" = "true" ]; then
cache_args=(--no-cache)
else
cache_args=(--cache-from "type=registry,ref=$IMAGE:buildcache")
fi
status=0
for platform in "${platforms[@]}"; do
@@ -97,8 +107,9 @@ jobs:
echo "::group::Build $platform"
docker buildx build --platform "$platform" --load --pull \
--file "$FILE" --tag "$tag" --build-arg "VERSION=$VERSION" \
--cache-from "type=registry,ref=$IMAGE:buildcache" \
--file "$FILE" --tag "$tag" \
--build-arg "VERSION=$VERSION" \
"${cache_args[@]}" \
"$CONTEXT"
echo "::endgroup::"
@@ -119,8 +130,9 @@ jobs:
exit $status
# Reuses the layers built above, so this mostly assembles and uploads.
# pull: false keeps the base images identical to the ones just scanned.
# Builds only from the builder's local cache, i.e. the layers built and
# scanned above (no cache-from), so it mostly assembles and uploads and
# the pushed image is the scanned one. pull: false keeps the base images.
- name: Build and push
uses: docker/build-push-action@v7
with:
@@ -133,5 +145,4 @@ jobs:
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
+1
View File
@@ -38,6 +38,7 @@ For x64 and arm64 (Raspberry Pi), add:
| `platforms` | `linux/amd64` | Comma-separated target platforms. Any `arm` platform enables QEMU emulation. |
| `context` | `.` | Docker build context. |
| `file` | `<context>/Dockerfile` | Path to the Dockerfile. |
| `no-cache` | `false` | Build without cache. Use `${{ gitea.event_name == 'schedule' }}` so weekly rebuilds pick up new packages. |
| `severity` | `CRITICAL,HIGH` | Severities that fail the build. Vulnerabilities without a fixed version never fail it. |
| `runs-on` | `linux-amd64` | Runner label. |