---
image: node:lts-slim

stages:
  - test
  - build
  - deploy

variables:
  NPM_ORGANIZATION: lydra

cache:
    key: ${CI_COMMIT_REF_SLUG}
    paths:
        - node_modules/

before_script:
  - npm ci

pages:
  stage: build
  script:
    - npm run build
    - mv public public.dist
    - mv dist public
  artifacts:
    paths:
      - public

publish_gitlab_registry:
  stage: deploy
  needs:
    - job: pages
      artifacts: true
  dependencies:
    - pages
  script:
    - npm config set -- '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
    - npm publish --access public
  # rules:
  #   - if: $CI_COMMIT_TAG
