stages:
  - deploy

# deploy-www.sh uses rsync -a which preserves symlinks. Several files
# under www/ are symlinks into ../whitepaper/ or other repo paths;
# those would land broken on the proxy. Walk every symlink in www/
# and copy its target in place, so any current or future symlink
# drops into this repo deploys transparently.
deploy:
  stage: deploy
  tags: ["proxy.uncloseai.com"]
  script:
    - |
      find www -type l | while read link; do
        target="${link}.real"
        cp -L "$link" "$target"
        mv "$target" "$link"
      done
    - echo "{\"commit\":\"$CI_COMMIT_SHA\",\"ref\":\"$CI_COMMIT_REF_NAME\"}" > www/version.json
    - sudo /usr/local/bin/deploy-www.sh lumbda www
  rules:
    - if: '$CI_COMMIT_REF_NAME == "master"'
