image: node:latest

stages:
  - build
  - test
  - publish

cache:
  paths:
    - node_modules/

build:
  stage: build
  script:
    - npm install
    - npm run build-docs
  artifacts:
    paths:
      - node_modules/
      - docs/
test:
  stage: test
  script: npm run test
  artifacts:
    when: always
    reports:
      junit:
        - junit.xml
publish:
  stage: publish
  dependencies:
    - build
    - test
  script:
    - rm -rf public/*
    - mv docs/ public/
  artifacts:
    paths:
      - public
    expire_in: 30 days
  only:
    - master
