# BlueGit CI for raytracer: tests, build game/editor bundle, FTP deploy of build/. # Secrets (repo): timftphost, timftpuser, timftppassword, timftproot (protected), # projectftp (expand; typically ${timftproot}raytracer). # GEEN mirror --delete (tuinslang-incident): live files mogen niet verdwijnen. # Deployt map build/ (NIET web/, NIET repo-root). stages: [test, build, deploy] workflow: rules: - if: $CI_COMMIT_TAG != "" when: never - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_BRANCH == "master" - if: $CI_COMMIT_BRANCH =~ /^feature\// unit_tests: stage: test image: node:20-bookworm script: - node --test test/*.test.js build_game: stage: build image: debian:bookworm-slim needs: [unit_tests] script: - apt-get update -qq && apt-get install -y -qq bash ca-certificates >/dev/null - chmod +x src/build.sh - ./src/build.sh - test -f build/game.js - test -f build/editor.js - test -f build/framework.js - test -f build/index.html - test -f build/editor.html - test -f build/levels.json - test -d build/images - test -d build/paperdolls artifacts: paths: - build/game.js - build/editor.js - build/index.html - build/editor.html - build/framework.js - build/levels.json expire_in: 7d ftp_upload: stage: deploy image: debian:bookworm-slim needs: [build_game] resource_group: production rules: # Alleen master push (protected secrets). Geen feature/MR-deploys. - if: $CI_COMMIT_BRANCH == "master" && $CI_PIPELINE_SOURCE != "merge_request_event" script: - apt-get update -qy - apt-get install -y --no-install-recommends lftp python3 ca-certificates # BlueGit expandeert $timftproot in secrets niet altijd; doe het zelf. - export projectftp="$(python3 -c 'import os;r=os.environ.get("timftproot","");print(os.environ["projectftp"].replace("${timftproot}",r).replace("$timftproot",r))')" - test -n "$projectftp" - | python3 - <<'PY' import os, sys p = os.environ["projectftp"].rstrip("/") root = os.environ.get("timftproot", "").rstrip("/") if not p or p == root or p == "/" or p == ".": print("REFUSING: projectftp is FTP-root or empty:", repr(p)) sys.exit(3) # Pad moet op dit project eindigen (voorkomt verkeerde secret). leaf = p.rsplit("/", 1)[-1] if leaf != "raytracer" and not p.endswith("/raytracer"): print("REFUSING: projectftp does not end with raytracer:", p) sys.exit(3) print("deploy target ok (path redacted length=%d leaf=%s)" % (len(p), leaf)) PY - test -f build/index.html - test -f build/editor.html - test -f build/game.js - test -d build/images # Upload alleen build/. GEEN --delete. Excludes: CI/shot-helpers/bron. - | printf '%s\n' \ 'set ssl:verify-certificate no' \ 'set sftp:auto-confirm yes' \ 'set xfer:use-temp-file yes' \ 'set cmd:fail-exit yes' \ "mkdir -p -f $projectftp" \ "cd $projectftp" \ 'mirror -R --exclude-glob .git/** --exclude-glob shot-*.html --exclude-glob shot-*.js --exclude-glob shot-*.png --exclude-glob blue-ci-cd.yml --exclude-glob README.md --exclude-glob .gitignore build/ .' \ 'bye' \ | lftp -u "$timftpuser","$timftppassword" "$timftphost"