executor: node

parameters:
  cache-version:
    type: string
  public-directory:
    type: string
    default: public

steps:
  - checkout
  - restore-cache:
      version: << parameters.cache-version >>
      cache-name: dependencies
  - attach_workspace:
      at: .
  - run:
      name: Build storybook
      command: yarn build-storybook -s << parameters.public-directory >>
      environment:
        APP_URL: /
        API_URL: /
        PUBLIC_URL: ""
  - persist_to_workspace:
      root: .
      paths:
        - storybook-static
