@@ -30,7 +30,8 @@ base_dir=$(basename "$(pwd)")
30
30
: " ${IMAGE_NAME:= $base_dir } "
31
31
: " ${LICENSE:= MIT} "
32
32
: " ${REGISTRY:= ghcr.io} "
33
- : " ${RUBY_VERSION:= 3.3.2} "
33
+ : " ${RUBY_VERSION:= 3.3.4} "
34
+ : " ${REGISTRY_TOKEN:= $GITHUB_TOKEN } "
34
35
35
36
base_image_tag=" $RUBY_VERSION -alpine$ALPINE_VERSION "
36
37
base_exists=$( skopeo list-tags docker://docker.io/ruby | jq -r " any(.Tags[] == \" $base_image_tag \" ; .)" )
@@ -155,7 +156,6 @@ if [ $# -gt 0 ]; then
155
156
shift
156
157
fi
157
158
158
-
159
159
if [ -z " $CONTAINERFILE " ]; then
160
160
printf " No containerfile specified, looking for default locations\n"
161
161
for containerfile in Containerfile Dockerfile
@@ -218,8 +218,8 @@ $runtime build --tag "$full_tag" "$@" \
218
218
--label org.opencontainers.image.revision=" $revision " \
219
219
--label org.opencontainers.image.url=" $repo_url " \
220
220
--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 " \
223
223
--label shortref=" $shortref " \
224
224
--build-arg ALPINE_VERSION=" $ALPINE_VERSION " \
225
225
--build-arg RUBY_VERSION=" $RUBY_VERSION " \
@@ -229,25 +229,26 @@ $runtime build --tag "$full_tag" "$@" \
229
229
if ! $runtime login --get-login " $REGISTRY " > /dev/null 2> /dev/null
230
230
then
231
231
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 "
234
234
fi
235
235
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}' )
237
238
for t in " ${tags[@]} "
238
239
do
239
240
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 "
241
242
if [ " $runtime " = " podman" ]
242
243
then
243
244
if [ " $full_tag " != " $new_tag " ]
244
245
then
246
+ debug " Tagging %s as %s\n" " $full_tag " " $new_tag "
245
247
podman tag " $full_tag " " $new_tag " || die 11 " Failed to tag image $full_tag as $new_tag "
246
248
fi
247
- registry_image_name=" $REGISTRY /$owner /$new_tag "
248
249
podman push " $new_tag " " $registry_image_name " || die 12 " Failed to push image $new_tag to $registry_image_name "
249
250
else
250
- registry_image_name= " $REGISTRY / $owner / $new_tag "
251
+ debug " Tagging %s as %s\n " " $full_tag " " $registry_image_name "
251
252
docker tag " $full_tag " " $registry_image_name " || die 13 " Failed to tag image $full_tag as $registry_image_name "
252
253
docker push " $registry_image_name " || die 14 " Failed to push image $new_tag to $registry_image_name "
253
254
fi
0 commit comments