MadKudu/node-eloqua

View on GitHub
.circleci/config.yml

Summary

Maintainability
Test Coverage
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
# Images at https://circleci.com/docs/2.0/circleci-images/

references:
  defaults: &defaults
    working_directory: ~/repo
    docker:
      - image: cimg/node:16.18.1

version: 2.1
jobs:
  build_job:
    <<: *defaults

    steps:
      - checkout
      - restore_cache:
          keys:
            - v1-deps-{{ checksum "package-lock.json" }}
            - v1-deps-
      - run: npm ci
      - save_cache:
          key: v1-deps-{{ checksum "package-lock.json" }}
          paths:
            - node_modules
      - run: npm run build

      - persist_to_workspace:
          root: ~/repo
          paths: .

  publish_job:
    <<: *defaults

    steps:
      - checkout
      - attach_workspace:
          at: ~/repo
      - run:
          name: Authenticate with registry
          command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
      - deploy:
          command: npm publish

workflows:
  version: 2
  build_and_deploy:
    jobs:
      - build_job:
          context: dev
      - publish_job:
          context: prod
          requires:
            - build_job
          filters:
            branches:
              only: master