Skip to content

Commit 37824d5

Browse files
committed
Properly set target-reference when input is set (#49)
Signed-off-by: Jakub Stejskal <xstejs24@gmail.com>
1 parent 3e102ae commit 37824d5

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

  • .github/actions/security/snyk-container-scan

.github/actions/security/snyk-container-scan/action.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ inputs:
1313
required: false
1414
default: "false"
1515
snykMonitorTargetReference:
16-
description: "Value for --target-reference in 'snyk container monitor' (e.g. release version). Defaults to the image tag."
16+
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."
1717
required: false
1818
default: ""
1919
uploadToCodeScanning:
@@ -100,7 +100,13 @@ runs:
100100
MONITOR_PROJECT="${LOADED_IMAGE%%:*}"
101101
MONITOR_REVISION="${LOADED_IMAGE##*:}"
102102
if [ -n "$TARGET_REFERENCE" ]; then
103-
MONITOR_REVISION="$TARGET_REFERENCE"
103+
TAG_PREFIX="${MONITOR_REVISION%%-*}"
104+
if [ "$TAG_PREFIX" != "$MONITOR_REVISION" ]; then
105+
TAG_SUFFIX="${MONITOR_REVISION#*-}"
106+
MONITOR_REVISION="${TARGET_REFERENCE}-${TAG_SUFFIX}"
107+
else
108+
MONITOR_REVISION="$TARGET_REFERENCE"
109+
fi
104110
fi
105111
snyk container monitor "$LOADED_IMAGE" \
106112
--project-name="$MONITOR_PROJECT" \

0 commit comments

Comments
 (0)