image: node:12

# Needs following env vars:
# - LFTP_PASSWORD
# - DEPLOY_SSH_KEY
deploy:
  tags:
    - docker
  environment: deployment
  variables:
    HTML_DIR: '/html/www'
    SSH_HOST: 'uploader@cloud.ok1kvk.cz'
  only:
    - master
  script:
    - node --version
    - apt update
    - apt -y install rsync
    - rm -rf build
    - npm ci
    - node ./index.js --dist
    - echo "$DEPLOY_SSH_KEY" > sshkey
    - chmod 600 sshkey
    - rsync -e 'ssh -i sshkey -o StrictHostKeyChecking=no' -rc --delete build/ $SSH_HOST:$HTML_DIR/
    - rm sshkey

cache:
  paths:
    - generator/
    - static/
