preview: variables: HTML_DIR: "/var/www/html/preview.ok1kvk.cz" SSH_HOST: "preview-ok1kvk-cz@alfa.ok1kvk.cz" environment: preview except: - master script: - node --version - rm -rf build - if [ -d generator ] ; then cd generator; git pull; cd ..; else git clone https://git.ok1kvk.cz/ok1kvk.cz/generator.git; fi - mkdir -p fake_static - cd generator/; npm install; cd .. - node generator/index.js --baseurl /$CI_BUILD_REF_NAME --contentdir . --staticdir fake_static --themedir generator/theme --builddir build --noserver - echo "$SSH_KEY" > sshkey - chmod 600 sshkey - rsync -e 'ssh -i sshkey' -rc --delete build/ $SSH_HOST:$HTML_DIR/$CI_BUILD_REF_NAME/ - ssh -i sshkey $SSH_HOST ln -fs $HTML_DIR/static/static $HTML_DIR/static/$CI_BUILD_REF_NAME - rm sshkey # Needs following env var: LFTP_PASSWORD deploy: environment: deployment only: - master script: - node --version - rm -rf build - if [ -d generator ] ; then cd generator; git pull; cd ..; else git clone https://git.ok1kvk.cz/ok1kvk.cz/generator.git; fi - if [ -d static ] ; then cd static; git pull; cd ..; else git clone https://git.ok1kvk.cz/ok1kvk.cz/static.git; fi - cd generator/; npm install; cd .. - node generator/index.js --contentdir . --staticdir static --themedir generator/theme --builddir build --noserver - generator/upload cache: paths: - generator/ - static/