image: 
  name: node:20
  pull_policy: if-not-present

stages:
  - build
  - deploy

gatsby-build:
  stage: build
  variables:
    CHOKIDAR_USEPOLLING: 1
    GATSBY_TELEMETRY_DISABLED: 1
  cache:
    paths:
    - .npm/
  script:
  - apt-get update && apt-get install -y libvips42 libvips-dev
  - npm config set registry https://registry.npmmirror.com
  - npm install -g npm@10.5.1
  - npm ci --cache .npm --prefer-offline
  - npm run build
  artifacts:
    paths:
    - public

deploy-webhook:
  stage: deploy
  only:
  - main
  script:
  - curl "$WEBHOOK_DEPLOY_URL"
  environment:
    name: staging
    url: https://mirrors.jcut.edu.cn/index