2017-06-02 03:16:19 +07:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-06-02 03:46:42 +07:00
|
|
|
# Parameters:
|
|
|
|
# TAG - The name of the tag to use for publishing in Dockerhub
|
2017-06-02 03:22:48 +07:00
|
|
|
|
2017-10-08 23:56:18 +07:00
|
|
|
function login_to_dockerhub {
|
2017-10-08 21:11:05 +07:00
|
|
|
echo "Logging in to Dockerhub as $DOCKER_USERNAME."
|
|
|
|
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
|
|
|
|
if [ "$?" -ne "0" ];
|
|
|
|
then
|
|
|
|
echo "Logging in to Dockerhub failed.";
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-10-08 23:56:18 +07:00
|
|
|
}
|
2017-06-02 03:32:35 +07:00
|
|
|
|
2017-10-08 23:56:18 +07:00
|
|
|
function deploy_on_dockerhub {
|
|
|
|
TAG=$1
|
2019-03-04 05:51:52 +07:00
|
|
|
IMAGE_NAME=authelia:dist
|
|
|
|
DOCKERHUB_IMAGE_NAME=clems4ever/authelia
|
|
|
|
IMAGE_WITH_TAG=$DOCKERHUB_IMAGE_NAME:$TAG
|
2017-10-08 23:56:18 +07:00
|
|
|
|
|
|
|
echo "==========================================================="
|
2017-06-02 03:32:35 +07:00
|
|
|
echo "Docker image $IMAGE_WITH_TAG will be deployed on Dockerhub."
|
2017-10-08 23:56:18 +07:00
|
|
|
echo "==========================================================="
|
2017-06-02 03:32:35 +07:00
|
|
|
docker tag $IMAGE_NAME $IMAGE_WITH_TAG;
|
|
|
|
docker push $IMAGE_WITH_TAG;
|
|
|
|
echo "Docker image deployed successfully."
|
2017-06-02 03:46:42 +07:00
|
|
|
}
|
2017-06-02 03:32:35 +07:00
|
|
|
|
2017-06-02 03:46:42 +07:00
|
|
|
|
2019-03-04 05:51:52 +07:00
|
|
|
if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
|
|
|
echo "Building on master branch"
|
2017-10-08 23:56:18 +07:00
|
|
|
login_to_dockerhub
|
|
|
|
deploy_on_dockerhub master
|
2017-06-02 03:46:42 +07:00
|
|
|
elif [ ! -z "$TRAVIS_TAG" ]; then
|
2017-10-08 23:56:18 +07:00
|
|
|
login_to_dockerhub
|
2017-06-02 03:46:42 +07:00
|
|
|
deploy_on_dockerhub $TRAVIS_TAG
|
2017-10-08 23:56:18 +07:00
|
|
|
deploy_on_dockerhub latest
|
2017-06-02 03:32:35 +07:00
|
|
|
else
|
|
|
|
echo "Docker image will not be deployed on Dockerhub."
|
2017-06-02 03:16:19 +07:00
|
|
|
fi
|
|
|
|
|