executor: node

parameters:
  cache-version:
    type: string
  store-artifacts:
    type: boolean
    default: false
  comment-script:
    type: string
    default: pr-comment

steps:
  - checkout
  - restore-cache:
      version: << parameters.cache-version >>
      cache-name: dependencies
  - attach_workspace:
      at: .
  - store_artifacts:
      path: storybook-static
  - run:
      name: Comment PR with artifacts
      command: |
        if [ -n "$CIRCLE_PULL_REQUEST" ]; then
          node scripts/<< parameters.comment-script >>.js
        fi
