services:
  - docker

env:
  global:
    - DOCKER_IMAGE_PREFIX=qwantresearch/kartotherian
  matrix:
    - SERVICE=load_db
    - SERVICE=tilerator
    - SERVICE=kartotherian
    - SERVICE=telegraf

branches:
  only:
    - master

before_install:
  - echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin

script:
  - export DOCKER_IMAGE="${DOCKER_IMAGE_PREFIX}_$SERVICE"
  - docker build --label "org.label-schema.vcs-ref=$TRAVIS_COMMIT" -t $DOCKER_IMAGE ./$SERVICE
  - docker push $DOCKER_IMAGE

services:
  - docker

env:
  global:
    - DOCKER_IMAGE_PREFIX=qwantresearch/kartotherian
  matrix:
    - SERVICE=load_db
    - SERVICE=tilerator
    - SERVICE=kartotherian
    - SERVICE=telegraf

before_install:
  - if [ "$TRAVIS_PULL_REQUEST_BRANCH" == "" ] && [ "$TRAVIS_BRANCH" == "master" ]; then
    echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin;
    fi

script:
  - export DOCKER_IMAGE="${DOCKER_IMAGE_PREFIX}_$SERVICE"
  - docker build --label "org.label-schema.vcs-ref=$TRAVIS_COMMIT" -t $DOCKER_IMAGE ./$SERVICE
  - if [ "$TRAVIS_PULL_REQUEST_BRANCH" == "" ] && [ "$TRAVIS_BRANCH" == "master" ]; then
    docker push $DOCKER_IMAGE;
    fi

Build PRs but don't push if not master
Build PRs but don't push if not master
