sudo: required
dist: trusty
language: node_js
services:
  - docker
node_js:
- '8.2.1'
cache:
  directories:
    - node_modules
    - server/node_modules
env:
  - NODE_ENV=production
install:
  - npm install --dev
script:
  - npm test
  - npm run build
after_success:
  - export REPO=martijnhols/wowanalyzer
  - export TAG=`if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo $TRAVIS_BRANCH; fi`
  - docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
  - docker build -f .dockerfile -t $REPO:$TRAVIS_COMMIT .
  - docker tag $REPO:$TRAVIS_COMMIT $REPO:$TAG
  - docker tag $REPO:$TRAVIS_COMMIT $REPO:travis-$TRAVIS_BUILD_NUMBER
  - docker push $REPO:$TAG

sudo: required
dist: trusty
language: node_js
services:
  - docker
node_js:
- '8.2.1'
cache:
  directories:
    - node_modules
    - server/node_modules
env:
  - NODE_ENV=production
install:
  - npm install --dev
script:
  - npm test
  - npm run build
after_success:
  - export REPO=martijnhols/wowanalyzer
  - export TAG=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo $TRAVIS_BRANCH; fi else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)
  - echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, PR=$PR, BRANCH=$BRANCH"
  - docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
  - docker build -f .dockerfile -t $REPO:$TRAVIS_COMMIT .
  - docker tag $REPO:$TRAVIS_COMMIT $REPO:$BRANCH
  - docker tag $REPO:$TRAVIS_COMMIT $REPO:travis-$TRAVIS_BUILD_NUMBER
  - docker push $REPO:$BRANCH

Fix issue where PRs might get the wrong container tags
Fix issue where PRs might get the wrong container tags
