sudo: required
services:
- docker
env:
  global:
    # Ensure the install happens without prompts
    - CLOUDSDK_CORE_DISABLE_PROMPTS=1
language: node_js
node_js:
- '6'
before_install:
- docker run --name mongo -p 27017:27017 -d mongo:3.2 
- docker run --name redis -p 6379:6379 -d redis:3.0 
- sleep 30s
- docker exec $(docker ps -aqf "name=mongo") mongo _GLOBAL --eval "db.getCollection('_Settings').insertOne({secureKey:'1227d1c4-1385-4d5f-ae73-23e99f74b006',clusterKey:'1227d1c4-1385-4d5f-ae73-23e99f74b006',myURL:'http://localhost:4730'});"
- docker run --name cloudboost -e MAIL_PROVIDER=$MAIL_PROVIDER -e MAIL_PROVIDER_API_KEY=$MAIL_PROVIDER_API_KEY -e DOMAIN=$DOMAIN -e FROM_EMAIL=$FROM_EMAIL -e FROM_NAME=$FROM_NAME -p 4730:4730 -it --link redis:redis --link mongo:mongo -d cloudboost/cloudboost:latest
- sleep 30s
install:
- npm install grunt-cli -g
- npm install
- grunt
after_success:
- echo "OK"
after_failure:
- docker logs cloudboost
- /usr/local/phantomjs/bin/phantomjs -v
before_deploy:
  - git config --global user.email "builds@travis-ci.com"
  - git config --global user.name "Travis CI"
  - export GIT_TAG=2.0.$TRAVIS_BUILD_NUMBER
  - git tag $GIT_TAG -a -m "Generated tag from TravisCI for build $TRAVIS_BUILD_NUMBER"
  - git push -q https://$GITLOGIN@github.com/CloudBoost/JavaScriptSDK --tags
deploy:
  provider: releases
  api_key: $GH_TOKEN
  file: "dist/cloudboost.js"
  skip_cleanup: true
  on:
    tags: false
    all_branches: true
after_deploy:
  # publish to npm
  - npm set init.author.name $NPM_USERNAME
  - npm set init.author.email $NPM_EMAIL
  - npm set init.author.url "https://cloudboost.io"
  - npm --no-git-tag-version version 2.0.$TRAVIS_BUILD_NUMBER --force
  - echo -e "$NPM_USERNAME\n$NPM_PASSWORD\n$NPM_EMAIL" | npm login
  - sleep 10s
  - npm publish
  - curl -X DELETE "https://api.cloudflare.com/client/v4/zones/""$cloudflare_zone""/purge_cache" -H "X-Auth-Email:test@cloudboost.io" -H "X-Auth-Key:""$cloud_flare_key" -H "Content-Type:application/json" --data "{'purge_everything':true}"
branches:
  except:
    - /^*-v[0-9]/
#Notify Team on Slack
notifications:
  slack: cloudboost:gm7nWJDLDtBRyF75VKLKOoMW
