version: 2

jobs:
  build:
    docker:
      - image: circleci/node:8.11
    working_directory: ~/project
    steps:
      - checkout
      - setup_remote_docker
      - run:
          name: Install
          command: npm install
      - run:
          name: Lint
          command: npm run lint
      - run:
          name: Test 
          command: npm run test
      - run:
          name: Build
          command: docker build -t cumuluss/cumulus-ecs-task .
      - run:
          name: Deploy
          command: |
            if [[  "$CIRCLE_BRANCH" == 'master' ]]; then
              echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
              ./bin/release.sh
            fi
