2020-09-25 09:18:45 +02:00
|
|
|
#!/bin/bash
|
|
|
|
set -x
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
function uploader {
|
|
|
|
gsutil cp $1 gs://$2/$1
|
|
|
|
gsutil -D setacl public-read gs://$2/$1 &> /dev/null
|
2021-01-11 11:17:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function publishImage {
|
|
|
|
echo "Publishing images to Docker Hub..."
|
|
|
|
echo "The images on the host:"
|
|
|
|
# for master, will use 'dev' as the tag name
|
|
|
|
# for release-*, will use 'release-*-dev' as the tag name, like release-v1.8.0-dev
|
|
|
|
if [[ $1 == "master" ]]; then
|
|
|
|
image_tag=dev
|
|
|
|
fi
|
|
|
|
if [[ $1 == "release-"* ]]; then
|
|
|
|
image_tag=$2-dev
|
|
|
|
fi
|
|
|
|
# rename the images with tag "dev" and push to Docker Hub
|
|
|
|
docker images
|
2021-01-12 03:01:50 +01:00
|
|
|
docker login -u $3 -p $4
|
2021-01-11 11:17:07 +01:00
|
|
|
docker images | grep goharbor | grep -v "\-base" | sed -n "s|\(goharbor/[-._a-z0-9]*\)\s*\(.*$2\).*|docker tag \1:\2 \1:$image_tag;docker push \1:$image_tag|p" | bash
|
|
|
|
echo "Images are published successfully"
|
|
|
|
docker images
|
2020-09-25 09:18:45 +02:00
|
|
|
}
|