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