From 6456e29c845594251ced599afc6b6c25d4be4e89 Mon Sep 17 00:00:00 2001 From: Jakub Stejskal Date: Sat, 20 Jun 2026 00:45:58 +0200 Subject: [PATCH] Properly set target-reference when input is set Signed-off-by: Jakub Stejskal --- .../actions/security/snyk-container-scan/action.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/actions/security/snyk-container-scan/action.yml b/.github/actions/security/snyk-container-scan/action.yml index 5e47db0..4b7d4d0 100644 --- a/.github/actions/security/snyk-container-scan/action.yml +++ b/.github/actions/security/snyk-container-scan/action.yml @@ -13,7 +13,7 @@ inputs: required: false default: "false" snykMonitorTargetReference: - description: "Value for --target-reference in 'snyk container monitor' (e.g. release version). Defaults to the image tag." + description: "Version prefix for --target-reference in 'snyk container monitor' (e.g. release version). Replaces only the version prefix of the image tag, preserving any suffix (e.g. kafka version, architecture). Defaults to the full image tag." required: false default: "" uploadToCodeScanning: @@ -100,7 +100,13 @@ runs: MONITOR_PROJECT="${LOADED_IMAGE%%:*}" MONITOR_REVISION="${LOADED_IMAGE##*:}" if [ -n "$TARGET_REFERENCE" ]; then - MONITOR_REVISION="$TARGET_REFERENCE" + TAG_PREFIX="${MONITOR_REVISION%%-*}" + if [ "$TAG_PREFIX" != "$MONITOR_REVISION" ]; then + TAG_SUFFIX="${MONITOR_REVISION#*-}" + MONITOR_REVISION="${TARGET_REFERENCE}-${TAG_SUFFIX}" + else + MONITOR_REVISION="$TARGET_REFERENCE" + fi fi snyk container monitor "$LOADED_IMAGE" \ --project-name="$MONITOR_PROJECT" \