sudo: required language: node_js node_js: 10 jobs: include: - stage: install, check code style and coverage if: tag IS blank services: - mongodb - docker addons: hosts: - localhost - dev-controller before_script: - npm install -g grunt-cli - docker pull soajsorg/soajs - sleep 10 script: - grunt - if [ "$TRAVIS_BRANCH" != "master" ]; then grunt test; fi - if [ "$TRAVIS_BRANCH" = "master" ]; then grunt coverage; fi - stage: Publish to npm if: branch =~ /(release)/ script: - echo "PUBLISH npm" deploy: skip_cleanup: true provider: npm email: $NPM_EMAIL api_key: $NPM_TOKEN on: all_branches: true condition: $TRAVIS_BRANCH =~ ^(release)* - stage: Publish to docker registry if: branch =~ /(release)/ script: - echo "PUBLISH docker" - export PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -Fn '{ print $2 }' | sed 's/[n:",]//g' | tr -d '[[:space:]]') - export MAJOR_VERSION=$(echo ${PACKAGE_VERSION} | awk -F. '{ print $1 }') - echo Package version ${PACKAGE_VERSION} - echo Major version ${MAJOR_VERSION} - git config --local user.name ${GIT_USER} - git config --local user.email ${GIT_EMAIL} - git tag ${PACKAGE_VERSION} - docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD - docker build -t soajsorg/dashboard . - docker images - docker tag soajsorg/dashboard:latest soajsorg/dashboard:${PACKAGE_VERSION} - docker tag soajsorg/dashboard:latest soajsorg/dashboard:${MAJOR_VERSION}.x - docker push soajsorg/dashboard deploy: on: all_branches: true provider: releases api_key: ${GIT_TOKEN} skip_cleanup: true