sudo: required
dist: trusty
language: java
before_install:
  - sudo add-apt-repository -y ppa:mc3man/trusty-media
  - sudo apt-get -qq update
  - sudo apt-get -y -q install ffmpeg mediainfo tesseract-ocr tesseract-ocr-fra tesseract-ocr-ita tesseract-ocr-kor tesseract-ocr-rus tesseract-ocr-ukr tesseract-ocr-spa tesseract-ocr-ara tesseract-ocr-hin tesseract-ocr-deu tesseract-ocr-pol tesseract-ocr-jpn tesseract-ocr-por tesseract-ocr-tha tesseract-ocr-jpn tesseract-ocr-chi-sim tesseract-ocr-chi-tra tesseract-ocr-nld tesseract-ocr-tur tesseract-ocr-heb tesseract-ocr-hun tesseract-ocr-fin tesseract-ocr-swe tesseract-ocr-lav tesseract-ocr-dan tesseract-ocr-nor
  - sudo apt-get -y -q install haveged && sudo service haveged start
after_success:
  - |
    if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
      mvn -Pprod -DskipTests clean install
      docker login -u $DOCKER_USER -p $DOCKER_PASS
      export REPO=sismics/docs
      export TAG=`if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo $TRAVIS_BRANCH ; fi`
      docker build -f Dockerfile -t $REPO:$COMMIT .
      docker tag $REPO:$COMMIT $REPO:$TAG
      docker tag $REPO:$COMMIT $REPO:travis-$TRAVIS_BUILD_NUMBER
      docker push $REPO
      cd docs-importer
      export REPO=sismics/docs-importer
      export TAG=`if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo $TRAVIS_BRANCH ; fi`
      docker build -f Dockerfile -t $REPO:$COMMIT .
      docker tag $REPO:$COMMIT $REPO:$TAG
      docker tag $REPO:$COMMIT $REPO:travis-$TRAVIS_BUILD_NUMBER
      docker push $REPO
    fi
env:
  global:
  - secure: LRGpjWORb0qy6VuypZjTAfA8uRHlFUMTwb77cenS9PPRBxuSnctC531asS9Xg3DqC5nsRxBBprgfCKotn5S8nBSD1ceHh84NASyzLSBft3xSMbg7f/2i7MQ+pGVwLncusBU6E/drnMFwZBleo+9M8Tf96axY5zuUp90MUTpSgt0=
  - secure: bCDDR6+I7PmSkuTYZv1HF/z98ANX/SFEESUCqxVmV5Gs0zFC0vQXaPJQ2xaJNRop1HZBFMZLeMMPleb0iOs985smpvK2F6Rbop9Tu+Vyo0uKqv9tbZ7F8Nfgnv9suHKZlL84FNeUQZJX6vsFIYPEJ/r7K5P/M0PdUy++fEwxEhU=
  - secure: ewXnzbkgCIHpDWtaWGMa1OYZJ/ki99zcIl4jcDPIC0eB3njX/WgfcC6i0Ke9mLqDqwXarWJ6helm22sNh+xtQiz6isfBtBX+novfRt9AANrBe3koCMUemMDy7oh5VflBaFNP0DVb8LSCnwf6dx6ZB5E9EB8knvk40quc/cXpGjY=
  - COMMIT=${TRAVIS_COMMIT::8}
