---
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

publish_gitlab_registry:
  stage: deploy
  needs:
    - job: build
      artifacts: true
  dependencies:
    - build
  script:
    - npm config set ${NPM_ORGANIZATION}:registry ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/npm/
    - npm config set -- '${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/npm/:_authToken' "${CI_JOB_TOKEN}"
    - npm config set -- '${CI_API_V4_URL}/packages/npm/:_authToken' "${CI_JOB_TOKEN}"
    - npm publish
  # rules:
  #   - if: $CI_COMMIT_TAG
