tricks/scripts/get-scan-report.sh
Elia el Lazkani 720bb64266
All checks were successful
continuous-integration/drone/push Build is passing
chore(): Adds logging credentials if existent
2023-07-04 19:18:15 +02:00

29 lines
692 B
Bash
Executable file

#!/bin/sh
set -e
image=$@
image_information=$(oras discover --artifact-type application/json "$image")
#printf "$image_information\n"
printf "Found image $image...\n"
report_digest=$(echo "$image_information" | tail -n1 | awk -F ' ' '{print $2}')
#printf "$report_digest\n"
printf "Found digests for scan report...\n"
extra_vars=""
if [[ -v REGISTRY_USERNAME ]]
then
extra_vars="$extra_vars --username $REGISTRY_USERNAME"
fi
if [[ -v REGISTRY_PASSWORD ]]
then
extra_vars="$extra_vars --password $REGISTRY_PASSWORD"
fi
image_base=$(echo "$image" | awk -F ':' '{print $1}')
printf "Pulling $image_base:@$report_digest...\n"
oras pull "$extra_vars" "$image_base:@$report_digest"