From 0c7b308f50de47232ef06580128b6ca33d9341d2 Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Thu, 26 Feb 2026 21:49:33 +0100 Subject: [PATCH] fix: Dockerfile handling with alias --- get-images-from-files/action.yaml | 8 ++++++-- get-images-from-files/test.Dockerfile | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/get-images-from-files/action.yaml b/get-images-from-files/action.yaml index 19c8875..0e36539 100644 --- a/get-images-from-files/action.yaml +++ b/get-images-from-files/action.yaml @@ -28,8 +28,12 @@ runs: images=$( for f in $file_list; do [ -f "$f" ] || continue - # Dockerfile: FROM [--platform=...] - awk '/^[[:space:]]*FROM[[:space:]]/ { print $NF }' "$f" 2>/dev/null || true + # Dockerfile: FROM [--platform=...] [AS ] + awk '/^[[:space:]]*FROM[[:space:]]/ { + for (i = 2; i <= NF; i++) { + if ($i !~ /^--/) { print $i; break } + } + }' "$f" 2>/dev/null || true # Kubernetes / Docker Compose: image: grep -E '[[:space:]]image:[[:space:]]' "$f" 2>/dev/null | sed 's/.*image:[[:space:]]*//' | awk '{ print $1 }' || true # Helmfile values: repository + tag (both required, by indent); tag without repo is skipped diff --git a/get-images-from-files/test.Dockerfile b/get-images-from-files/test.Dockerfile index 4aa49e0..9ce0c9b 100644 --- a/get-images-from-files/test.Dockerfile +++ b/get-images-from-files/test.Dockerfile @@ -4,7 +4,7 @@ FROM example.com/library/nginx:v1 # Registry path with tag — shared with K8s to test deduplication FROM example.com/distroless/static:nonroot # Registry with digest (Dockerfile) -FROM example.com/library/base@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +FROM example.com/library/base@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa AS base # Ignored tags ## Short repo:tag (ignored by design; only registry refs are extracted)