2018-10-05 10:51:35 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-01-24 15:23:25 +02:00
|
|
|
# Skip deploy for staging branch
|
2021-11-17 22:00:04 +02:00
|
|
|
[ "$BRANCH" = "staging" ] && exit 0
|
2019-01-24 15:23:25 +02:00
|
|
|
|
|
|
|
docker login -u $DOCKER_UN -p $DOCKER_PW
|
2021-11-17 22:00:04 +02:00
|
|
|
|
|
|
|
if [ "$BRANCH" = "testing" ]
|
|
|
|
then
|
|
|
|
docker-compose -f tests/build.yml push
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
#Deploy for main releases
|
|
|
|
#Images are built with tag PINNED_MAILU_VERSION (x.y.z).
|
|
|
|
#We are tagging them as well with MAILU_VERSION (x.y)
|
|
|
|
#After that, both tags are pushed to the docker repository.
|
|
|
|
if [ "$PINNED_MAILU_VERSION" != "" ] && [ "$BRANCH" != "master" ]
|
|
|
|
then
|
2021-12-05 18:10:55 +02:00
|
|
|
images=$(docker-compose -f tests/build.yml config | awk -F ':' '/image:/{ print $2 }')
|
2021-11-17 22:00:04 +02:00
|
|
|
for image in $images
|
|
|
|
do
|
|
|
|
docker tag "${image}":"${PINNED_MAILU_VERSION}" "${image}":${MAILU_VERSION}
|
|
|
|
done
|
|
|
|
#Push PINNED_MAILU_VERSION images
|
|
|
|
docker-compose -f tests/build.yml push
|
|
|
|
#Push MAILU_VERSION images
|
|
|
|
PINNED_MAILU_VERSION=$MAILU_VERSION
|
|
|
|
docker-compose -f tests/build.yml push
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
#Deploy for master. For master we only publish images with tag master
|
|
|
|
#Images are built with tag PINNED_MAILU_VERSION (commit hash).
|
|
|
|
#We are tagging them as well with MAILU_VERSION (master)
|
|
|
|
#Then we publish the images with tag master
|
|
|
|
if [ "$PINNED_MAILU_VERSION" != "" ] && [ "$BRANCH" == "master" ]
|
|
|
|
then
|
2021-12-05 18:10:55 +02:00
|
|
|
images=$(docker-compose -f tests/build.yml config | awk -F ':' '/image:/{ print $2 }')
|
2021-11-17 22:00:04 +02:00
|
|
|
for image in $images
|
|
|
|
do
|
|
|
|
docker tag "${image}":"${PINNED_MAILU_VERSION}" "${image}":${MAILU_VERSION}
|
|
|
|
done
|
|
|
|
#Push MAILU_VERSION images
|
|
|
|
PINNED_MAILU_VERSION=$MAILU_VERSION
|
|
|
|
docker-compose -f tests/build.yml push
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
#Fallback in case $PINNED_MAILU_VERSION is empty. This should never execute.
|
2019-01-24 15:23:25 +02:00
|
|
|
docker-compose -f tests/build.yml push
|