stages:
  - name: test
    if: NOT branch IN (master, staging)
  - name: deploy
    if: branch IN (master, staging) OR tag =~ ^v\d+

jobs:
  include:
    - stage: test
      language: node_js
      node_js: [node]
      cache: {directories: [node_modules]}
      script:
        - npm test
    - stage: deploy
      language: generic
      sudo: required
      services: [docker]
      env:
        - CF_FRONTEND_IMAGE=captainfact/frontend:$TRAVIS_BRANCH
      script:
        - docker build --build-arg BUILD_ENV=$TRAVIS_BRANCH -t $CF_FRONTEND_IMAGE . &&
          docker run --rm -it $CF_FRONTEND_IMAGE test &&
          if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
              docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
              echo "Pushing $CF_FRONTEND_IMAGE";
              docker push $CF_FRONTEND_IMAGE;
          fi


stages:
  - name: test
    if: NOT branch IN (master, staging)
  - name: deploy
    if: branch IN (master, staging) OR tag =~ ^v\d+

jobs:
  include:
    - stage: test
      language: node_js
      node_js: [node]
      cache: {directories: [node_modules]}
      script:
        - npm test
    - stage: deploy
      language: generic
      sudo: required
      services: [docker]
      env:
        - CF_FRONTEND_IMAGE=captainfact/frontend:$TRAVIS_BRANCH
      script:
        - docker --version
        - docker build --build-arg BUILD_ENV=$TRAVIS_BRANCH -t $CF_FRONTEND_IMAGE . &&
          docker run --rm -it $CF_FRONTEND_IMAGE test &&
          if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
              docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";
              echo "Pushing $CF_FRONTEND_IMAGE";
              docker push $CF_FRONTEND_IMAGE;
          fi


Add debug messages to CI
Add debug messages to CI

