Skip to content

Commit

Permalink
Improve Travis deployment process
Browse files Browse the repository at this point in the history
  • Loading branch information
eexit committed Dec 2, 2015
1 parent 0f4eaed commit 4cf9eed
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
13 changes: 13 additions & 0 deletions docker-push
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4cf9eed

Please sign in to comment.