image: node:20.18.3

stages:
  - build
  - deploy

variables:
  GIT_DEPTH: 0
  GIT_STRATEGY: clone
  GIT_SUBMODULE_STRATEGY: recursive

cache:
  key:
    files:
      - pnpm-lock.yaml
  paths:
    - node_modules/
    - .pnpm-store/

default:
  tags:
    - public-runner-docker

.npm_based_job:
  before_script:
    - corepack enable
    - corepack prepare pnpm@10.0.0 --activate
    - pnpm config set store-dir .pnpm-store
    - pnpm install --frozen-lockfile

build:
  extends: .npm_based_job
  stage: build
  script:
    - pnpm build
  artifacts:
    paths:
      - dist
    when: always
    expire_in: 1 week

pages:
  stage: deploy
  script:
    - echo "The site will be deployed to $CI_PAGES_URL"
  publish: dist
  artifacts:
    paths:
      - dist
  only:
    - main
