| 1 | # BlueGit CI: nieuw (GitLab had geen .gitlab-ci.yml). Alleen FTP-upload van publieke sitebestanden. |
| 2 | # Secrets (repo, beschermd, van GitLab-groep blue-star + projectftp): timftphost, timftpuser, timftppassword, timftproot, projectftp. |
| 3 | # GEEN mirror --delete: GitLab wiste nooit iets via CI; live data mag niet verdwijnen. |
| 4 | stages: [test, deploy] |
| 5 | |
| 6 | sanity_check: |
| 7 | stage: test |
| 8 | image: debian:bookworm-slim |
| 9 | script: |
| 10 | - test -f index.html |
| 11 | - test -f js/game.js |
| 12 | - test -f js/framework.js |
| 13 | - test -d images |
| 14 | - test -d sounds |
| 15 | - test ! -f blue-ci-cd.yml || true |
| 16 | |
| 17 | ftp_upload: |
| 18 | stage: deploy |
| 19 | image: debian:bookworm-slim |
| 20 | needs: [sanity_check] |
| 21 | resource_group: production |
| 22 | rules: |
| 23 | - if: $CI_COMMIT_BRANCH == "master" && $CI_PIPELINE_SOURCE != "merge_request_event" |
| 24 | script: |
| 25 | - apt-get update -qy |
| 26 | - apt-get install -y --no-install-recommends lftp python3 ca-certificates |
| 27 | # BlueGit expandeert $timftproot in secrets niet (GitLab deed dat wel). |
| 28 | - export projectftp="$(python3 -c 'import os;r=os.environ.get("timftproot","");print(os.environ["projectftp"].replace("${timftproot}",r).replace("$timftproot",r))')" |
| 29 | - test -n "$projectftp" |
| 30 | # Guard: nooit de FTP-root zelf, en pad moet op dit project eindigen. |
| 31 | - | |
| 32 | python3 - <<'PY' |
| 33 | import os,sys |
| 34 | p=os.environ["projectftp"].rstrip("/") |
| 35 | root=os.environ.get("timftproot","").rstrip("/") |
| 36 | if not p or p==root or p=="/": |
| 37 | print("REFUSING: projectftp is FTP-root or empty:", p); sys.exit(3) |
| 38 | if not p.endswith("cellular-evolution"): |
| 39 | print("REFUSING: projectftp does not end with cellular-evolution:", p); sys.exit(3) |
| 40 | print("deploy target ok") |
| 41 | PY |
| 42 | # Alleen publieke sitebestanden; GEEN --delete. src/.vscode/README blijven lokaal. |
| 43 | - | |
| 44 | printf 'set ssl:verify-certificate no\nset sftp:auto-confirm yes\nset cmd:fail-exit yes\ncd "%s"\nmirror -R --exclude-glob .git/** --exclude-glob .vscode/** --exclude-glob src/** --exclude-glob README.md --exclude-glob blue-ci-cd.yml --exclude-glob .gitignore --exclude-glob Thumbs.db ./ .\nbye\n' "$projectftp" | lftp -u "$timftpuser","$timftppassword" "$timftphost" |