@@ -30,7 +30,8 @@ base_dir=$(basename "$(pwd)")
3030: " ${IMAGE_NAME:= $base_dir } "
3131: " ${LICENSE:= MIT} "
3232: " ${REGISTRY:= ghcr.io} "
33- : " ${RUBY_VERSION:= 3.3.2} "
33+ : " ${RUBY_VERSION:= 3.3.4} "
34+ : " ${REGISTRY_TOKEN:= $GITHUB_TOKEN } "
3435
3536base_image_tag=" $RUBY_VERSION -alpine$ALPINE_VERSION "
3637base_exists=$( skopeo list-tags docker://docker.io/ruby | jq -r " any(.Tags[] == \" $base_image_tag \" ; .)" )
@@ -155,7 +156,6 @@ if [ $# -gt 0 ]; then
155156 shift
156157fi
157158
158-
159159if [ -z " $CONTAINERFILE " ]; then
160160 printf " No containerfile specified, looking for default locations\n"
161161 for containerfile in Containerfile Dockerfile
@@ -218,8 +218,8 @@ $runtime build --tag "$full_tag" "$@" \
218218 --label org.opencontainers.image.revision=" $revision " \
219219 --label org.opencontainers.image.url=" $repo_url " \
220220 --label org.opencontainers.image.title=" $IMAGE_NAME " \
221- --label org.opencontainers.image.source=" Generated by gitops_tools/bin/ build_image ($USER @$HOSTNAME )" \
222- --label org.opencontainers.image.version=" $tag " \
221+ --label org.opencontainers.image.source=" Generated by ruby-automation's build_image.sh ($USER @$HOSTNAME )" \
222+ --label org.opencontainers.image.version=" $full_tag " \
223223 --label shortref=" $shortref " \
224224 --build-arg ALPINE_VERSION=" $ALPINE_VERSION " \
225225 --build-arg RUBY_VERSION=" $RUBY_VERSION " \
@@ -229,25 +229,26 @@ $runtime build --tag "$full_tag" "$@" \
229229if ! $runtime login --get-login " $REGISTRY " > /dev/null 2> /dev/null
230230then
231231 printf " Not logged in to '%s', trying to login\n" " $REGISTRY " >&2
232- [ -z " $GITHUB_TOKEN " ] && die 9 " No GITHUB_TOKEN set, cannot login"
233- printf " %s" " $GITHUB_TOKEN " | $runtime login -u " $GITHUB_TOKEN " --password-stdin " $REGISTRY " || die 10 " Failed to login to $REGISTRY "
232+ [ -z " $REGISTRY_TOKEN " ] && die 9 " No REGISTRY_TOKEN (nor GITHUB_TOKEN) set, cannot login"
233+ printf " %s" " $REGISTRY_TOKEN " | $runtime login -u " $REGISTRY_TOKEN " --password-stdin " $REGISTRY " || die 10 " Failed to login to $REGISTRY "
234234fi
235235
236- mapfile -t tags < <( echo " $tag " | awk -F' .' ' NF==3{print $1"."$2"."$3; print $1"."$2; print $1; next} NF==2{print $1"."$2; print $1; next} {print}' )
236+ # Split 1.2.3 into 1.2.3, 1.2, 1. We want to tag our image with all 3 of these
237+ mapfile -t tags < <( echo " $tag " | awk -F' .' ' NF==3{print; print $1"."$2; print $1; next} NF==2{print; print $1; next} {print}' )
237238for t in " ${tags[@]} "
238239do
239240 new_tag=$IMAGE_NAME :$t -ruby$RUBY_VERSION -alpine$ALPINE_VERSION
240- debug " Tagging %s as %s\n " " $full_tag " " $new_tag "
241+ registry_image_name= " $REGISTRY / $owner / $new_tag "
241242 if [ " $runtime " = " podman" ]
242243 then
243244 if [ " $full_tag " != " $new_tag " ]
244245 then
246+ debug " Tagging %s as %s\n" " $full_tag " " $new_tag "
245247 podman tag " $full_tag " " $new_tag " || die 11 " Failed to tag image $full_tag as $new_tag "
246248 fi
247- registry_image_name=" $REGISTRY /$owner /$new_tag "
248249 podman push " $new_tag " " $registry_image_name " || die 12 " Failed to push image $new_tag to $registry_image_name "
249250 else
250- registry_image_name= " $REGISTRY / $owner / $new_tag "
251+ debug " Tagging %s as %s\n " " $full_tag " " $registry_image_name "
251252 docker tag " $full_tag " " $registry_image_name " || die 13 " Failed to tag image $full_tag as $registry_image_name "
252253 docker push " $registry_image_name " || die 14 " Failed to push image $new_tag to $registry_image_name "
253254 fi
0 commit comments