fuzzyworld

tower / files / .fw-ci.yml

.fw-ci.yml

1.6 KB · history · blame

1image: node:22
2
3stages: [test, deploy]
4
5test:
6 stage: test
7 script:
8 - npm ci
9 - npm test
10 - npm run build
11
12pages:
13 stage: deploy
14 variables:
15 GIT_DEPTH: "0"
16 script:
17 # The default branch at the root, every other branch at /<branch>/ (build-pages.sh).
18 - sh tools/build-pages.sh public
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)
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)
25 artifacts:
26 paths: [public]
27 rules:
28 - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
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.
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.
37preview:
38 stage: deploy
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"
44 rules:
45 - if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH