stages:
  - build
  - deploy

# cache:
#   key: "$CI_COMMIT_REF_SLUG"
#   paths:
#     - .npm/

build_pre:
  stage: build
  image: node:20-bullseye
  tags:
    - risk-monitor-frontend
  only:
    - pre
  script:
    - node -v
    - npm -v
    - npm config set cache .npm --global
    - npm ci --prefer-offline --no-audit --no-fund
    - npm run build
  artifacts:
    paths:
      - dist/
    expire_in: 1 hour

deploy_pre:
  stage: deploy
  image: alpine:3.20
  tags:
    - risk-monitor-frontend
  only:
    - pre
  dependencies:
    - build_pre
  script:
    - apk add --no-cache rsync
    - rsync -av --delete dist/ /nas/kjb_service/zm/pre-project/html/