From 4cf9eed1015421d2c868b494651bd13b88b1f491 Mon Sep 17 00:00:00 2001 From: Joris Berthelot <admin@eexit.net> Date: Wed, 2 Dec 2015 15:35:37 +0100 Subject: [PATCH] Improve Travis deployment process --- .travis.yml | 9 +++++---- docker-push | 13 +++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) create mode 100755 docker-push diff --git a/.travis.yml b/.travis.yml index e4cc4d9..adb71f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,8 @@ sudo: required env: global: - TAG_PATTERN="^[0-9]+(\.[0-9]+){2}(-(alpha|beta|rc))?$" - - DOCKER_IMAGE=eexit/mirror-http-server:${TRAVIS_TAG:=$TRAVIS_BUILD_NUMBER} + - DOCKER_IMAGE=eexit/mirror-http-server + - DOCKER_TAG=${TRAVIS_TAG:=$TRAVIS_BUILD_NUMBER} services: - docker @@ -12,10 +13,10 @@ before_install: - docker login --email=$DOCKER_EMAIL --username=$DOCKER_USER --password=$DOCKER_PASSWD install: - - docker build -t $DOCKER_IMAGE . + - docker build -t $DOCKER_IMAGE:$DOCKER_TAG . script: - - docker run $DOCKER_IMAGE npm test + - docker run $DOCKER_IMAGE:$DOCKER_TAG npm test after_success: - - if [[ "$TRAVIS_TAG" =~ $TAG_PATTERN ]]; then docker push $DOCKER_IMAGE; fi + - $(pwd)/docker-push diff --git a/docker-push b/docker-push new file mode 100755 index 0000000..8cbb10c --- /dev/null +++ b/docker-push @@ -0,0 +1,13 @@ +#!/bin/bash +set -e + +if [[ "$TRAVIS_TAG" =~ $TAG_PATTERN ]]; then + echo "Pushing $DOCKER_IMAGE:$DOCKER_TAG" + docker push $DOCKER_IMAGE:$DOCKER_TAG; + + echo "Tagging $DOCKER_IMAGE:$DOCKER_TAG as $DOCKER_IMAGE:latest" + docker tag $DOCKER_IMAGE:$DOCKER_TAG $DOCKER_IMAGE:latest + + echo "Pushing $DOCKER_IMAGE:latest" + docker push $DOCKER_IMAGE:latest +fi