version: 2
jobs:
  build:
    working_directory: ~/Clever/underscore.deep
    docker:
    - image: circleci/node:12-stretch
    environment:
      CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
      CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
    steps:
    - run:
        command: cd $HOME && git clone --depth 1 -v https://github.com/Clever/ci-scripts.git && cd ci-scripts && git show --oneline -s
        name: Clone ci-scripts
    - checkout
    - run:
        command: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
        name: Set up CircleCI artifacts directories
    - run:
        name: Set up .npmrc
        command: |
          sed -i.bak s/\${npm_auth_token}/$NPM_TOKEN/ .npmrc_docker
          mv .npmrc_docker .npmrc
    - run: npm ci
    - run: make build
    - run: make test
    - run: if [ "${CIRCLE_BRANCH}" == "master" ]; then $HOME/ci-scripts/circleci/npm-publish $NPM_TOKEN .; fi;