version: 2.1
orbs:
  node: circleci/node@5.0.2

jobs:
  sunbird_build_json:
    executor: node/default
    steps:
      - checkout
      - node/install-packages:
          pkg-manager: yarn
      - run:
          name: Check current version of node
          command: node -v
      - run:
          name: Build app
          command: npm run build
      - run:
          name: Publish to NPM
          command: |
            if [ -z $CIRCLE_PR_NUMBER ]; then
              echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
              npm publish --accesss=public
            else
              echo "skipping npm publish"
            fi

workflows:
    version: 2
    sunbird_resource_bundles:
      jobs:
        - sunbird_build_json