language: c
sudo: required
dist: trusty
services:
  - docker
cache:
  apt: true
  directories:
    - $HOME/.opam
    - $HOME/.sbt
    - $HOME/.ivy2
    - $HOME/.apk-cache
before_cache:
  - rm -rfv $HOME/.opam/log ;
    if [ "$TRAVIS_TEST_RESULT" = "0" -a "$TRAVIS_BRANCH" = "master" ]; then
    LAST_UI_SHA=$( cat $HOME/.apk-cache/.last_ui_sha );
    UI_SHA=$( curl -s -H "Accept:application/vnd.github.v3.sha" https://api.github.com/repos/keyfender/keyfender-ui/commits/master );
    if [ "$TRAVIS_EVENT_TYPE" = "push" -o "$UI_SHA" != "$LAST_UI_SHA" ]; then
    echo -n $UI_SHA > $HOME/.apk-cache/.last_ui_sha ;
    docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
    export REPO=keyfender/keyfender;
    docker tag $REPO:latest $REPO:${TRAVIS_COMMIT::7};
    docker tag $REPO:latest $REPO:travis-$TRAVIS_BUILD_NUMBER;
    docker push $REPO;
    fi
    fi
install: bash -ex .travis-install.sh
script: bash -ex .travis-script.sh
notifications:
  webhooks:
    urls:
    - "https://scalar.vector.im/api/neb/services/hooks/dHJhdmlzLWNpLyU0MGFuc2l3ZW4lM0FtYXRyaXgub3JnLyUyMUJtb0NiTllKVVNFS2JwSlFrTyUzQWE2bi5kZQ"
    on_success: change  # always|never|change
    on_failure: always
    on_start: never
