all:
  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
    - mkdir -p upload
    - echo $LFTP_PASSWORD | sshfs -o password_stdin,reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 -p 2121 ok1kvk.cz-www-nove@krios.blueboard.cz:/ upload
    - /usr/bin/time -f "Upload took %e" -- node generator/sftp-sync.js --sourcedir build --server localdirectory --targetdir upload --port 2121
    - fusermount -u upload
    - rm -rf upload

cache:
  paths:
    - generator/
    - static/

# Needs following env var: LFTP_PASSWORD

