image: node:8.12-alpine

cache:
  paths:
    - node_modules/

before_script:
  - npm install

stages:
  - test
  - deploy

test:
  stage: test
  script:
    - npm run test

pages:
  stage: deploy
  script:
    - npm run doc
    - mkdir public
    - mv doc/fixings/1.2.0/* public/
  artifacts:
    paths:
      - public
  only:
    - master

publish:
  stage: deploy
  only:
    - master
    - tags
    - triggers
  script:
    - echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > .npmrc
    - npm publish
