tricks/scripts/attach-scan-report
Elia el Lazkani ca43188adf
Some checks are pending
continuous-integration/drone/push Build is running
chore(): Adds new attach scan report script
2023-07-04 23:11:09 +02:00

31 lines
846 B
Bash
Executable file

#!/bin/sh
set -xe
TIMESTAMP=$(date "+%F %T %Z")
image="$@"
printf "Set image to $image...\n"
extra_vars=""
if [ ! -z $REGISTRY_USERNAME ]; then
printf "Found registry username...\n"
extra_vars="$extra_vars --username $REGISTRY_USERNAME"
fi
if [ ! -z $REGISTRY_PASSWORD ]; then
printf "Found registry password\n"
extra_vars="$extra_vars --password $REGISTRY_PASSWORD"
fi
extra_vars="$extra_vars -a \"org.opencontainers.trivy.created=$TIMESTAMP\" -a \"org.opencontainers.trivy.status=Passed\" -a \"org.opencontainers.trivy.tag=${DRONE_COMMIT_SHA:0:8}\""
printf "Checking for result file...\n"
if [ -e result.json ]; then
printf "Result file found, attaching it to container...\n"
oras attach $extra_vars --artifact-type=application/json $image "result.json"
else
printf "Result file not found !\n"
exit 1
fi