datacite/spinone

View on GitHub
.travis.yml

Summary

Maintainability
Test Coverage
language: ruby
rvm:
- 2.4.1
sudo: required

services:
  - docker
  - memcached

addons:
  code_climate:
    repo_token: $CODECLIMATE_REPO_TOKEN

install:
  - travis_retry bundle install
  - curl -sL https://sentry.io/get-cli/ | bash
  - sentry-cli --version

before_script:
  - memcached -p 11211 &

script:
  - bundle exec rspec spec
  - bundle exec codeclimate-test-reporter || true

after_success:
  - set -e
  - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";
  - REPO=datacite/spinone;
  - AUTO_DEPLOY=false;
  - if [ "${TRAVIS_TAG?}" ]; then
      docker build -f Dockerfile -t $REPO:$TRAVIS_TAG .;
      docker push $REPO:$TRAVIS_TAG;
      echo "Pushed to" $REPO:$TRAVIS_TAG;
      AUTO_DEPLOY=true;
    elif [ "$TRAVIS_BRANCH" == "master" ]; then
      docker build -f Dockerfile -t $REPO .;
      docker push $REPO;
      echo "Pushed to" $REPO;
      AUTO_DEPLOY=true;
    else
      docker build -f Dockerfile -t $REPO:$TRAVIS_BRANCH .;
      docker push $REPO:$TRAVIS_BRANCH;
      echo "Pushed to" $REPO:$TRAVIS_BRANCH;
    fi

  - if [ "$AUTO_DEPLOY" == "true" ]; then
      wget https://github.com/jwilder/dockerize/releases/download/v0.6.0/dockerize-linux-amd64-v0.6.0.tar.gz;
      tar -xzvf dockerize-linux-amd64-v0.6.0.tar.gz;
      rm dockerize-linux-amd64-v0.6.0.tar.gz;
      export GIT_SHA=$(git rev-parse --short HEAD);
      export GIT_TAG=$(git describe --tags $(git rev-list --tags --max-count=1));
      git clone "https://${TRAVIS_SECURE_TOKEN}@github.com/datacite/mastino.git";
      ./dockerize -template vendor/docker/_spinone.auto.tfvars.tmpl:mastino/stage/services/api/_spinone.auto.tfvars;
      
      sentry-cli releases new spinone:${GIT_TAG} --finalize --project spinone;

      if [ "${TRAVIS_TAG?}" ]; then
        ./dockerize -template vendor/docker/_spinone.auto.tfvars.tmpl:mastino/prod-eu-west/services/api/_spinone.auto.tfvars;
        sentry-cli releases deploys spinone:${GIT_TAG} new -e production;
      else
        sentry-cli releases deploys spinone:${GIT_TAG} new -e stage;
      fi

      sentry-cli releases set-commits --auto spinone:${GIT_TAG};

      cd mastino;
      git remote;
      git config user.email ${DOCKER_EMAIL};
      git config user.name ${DOCKER_USERNAME};
      
      if [ "${TRAVIS_TAG?}" ]; then
        git add prod-eu-west/services/api/_spinone.auto.tfvars;
      else
        git add stage/services/api/_spinone.auto.tfvars;
      fi

      git commit -m "Adding spinone git variables for latest commit";
      git push "https://${TRAVIS_SECURE_TOKEN}@github.com/datacite/mastino.git" master;
    fi

notifications:
  slack: datacite:Wt8En0ALoTA6Kjc5EOKNDWxN
  email: false