cf4f8772 2026-09-07 Pavel Safronov | 1 | image: node:22 |
| 2 | |
| 3 | stages: [test, deploy] |
| 4 | |
| 5 | test: |
| 6 | stage: test |
| 7 | script: |
| 8 | - npm ci |
| 9 | - npm test |
| 10 | - npm run build |
| 11 | |
| 12 | pages: |
| 13 | stage: deploy |
342ab851 2026-09-28 Pavel Safronov | 14 | variables: |
| 15 | GIT_DEPTH: "0" |
cf4f8772 2026-09-07 Pavel Safronov | 16 | script: |
342ab851 2026-09-28 Pavel Safronov | 17 | # The default branch at the root, every other branch at /<branch>/ (build-pages.sh). |
| 18 | - sh tools/build-pages.sh public |
62458672 2026-09-07 Pavel Safronov | 19 | # Fail loudly rather than publishing a 404. `mv` silently nests when the |
| 20 | # destination exists, which is exactly how this broke the first time. |
| 21 | - test -f public/index.html || (echo "no index.html at artifact root" && exit 1) |
3413c443 2026-09-19 Pavel Safronov | 22 | # The terrain worker must be bundled as its own chunk. When it was not, the build |
| 23 | # passed and the site hung forever on "Reading the plans" (service.ts). |
| 24 | - ls public/assets/worker-*.js || (echo "terrain worker was not bundled" && exit 1) |
cf4f8772 2026-09-07 Pavel Safronov | 25 | artifacts: |
| 26 | paths: [public] |
| 27 | rules: |
| 28 | - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH |
342ab851 2026-09-28 Pavel Safronov | 29 | |
| 30 | # A push to any other branch rebuilds the site from the default branch, which is what |
| 31 | # builds that branch's preview at /<branch>/. Parallel deployments would do this |
| 32 | # natively, but they are Premium-only and this project is on the Free plan. |
4903aa48 2026-09-28 Pavel Safronov | 33 | # |
| 34 | # Through the trigger API, with a pipeline trigger token in PAGES_TRIGGER_TOKEN (a masked |
| 35 | # CI/CD variable): a `trigger:` job cannot start a pipeline in its own project, and |
| 36 | # GitLab refuses it as invalid_bridge_trigger. |
342ab851 2026-09-28 Pavel Safronov | 37 | preview: |
| 38 | stage: deploy |
4903aa48 2026-09-28 Pavel Safronov | 39 | script: |
| 40 | - > |
| 41 | curl --fail --silent --show-error --output /dev/null |
| 42 | --form "token=$PAGES_TRIGGER_TOKEN" --form "ref=$CI_DEFAULT_BRANCH" |
| 43 | "$CI_API_V4_URL/projects/$CI_PROJECT_ID/trigger/pipeline" |
342ab851 2026-09-28 Pavel Safronov | 44 | rules: |
| 45 | - if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH |