stages:
  - build
  - test
  - publish
  - ci_status
  
image: node:12.18.4

workflow:
  rules:
    - if: $CI_COMMIT_BRANCH

test:
  stage: test
  before_script:
    - |
      {
        echo "@${CI_PROJECT_ROOT_NAMESPACE}:registry=${CI_API_V4_URL}/packages/npm/"
      } | tee --append .npmrc
    - npm ci --cache .npm --prefer-offline
  script:
    - npm run test

include:
  - project: telios2/telios-devops
    ref: master 
    file: ".gitlab-ci.DiscordWebhook.yml"
  - project: telios2/telios-devops
    ref: master 
    file: ".gitlab-ci.NPMPublish.yml"
  - template: Secret-Detection.gitlab-ci.yml
  - template: SAST.gitlab-ci.yml
  - template: License-Scanning.gitlab-ci.yml
  - template: Dependency-Scanning.gitlab-ci.yml

publish:npm:
  stage: publish
  extends: .publish:npm
