# Needs following env vars:
# - LFTP_PASSWORD

build and deploy:
  stage: deploy
  tags:
    - shell
  only:
    - main
  variables:
    FTP_DIR: '/www/nove/'
    FTP_HOST: 'krios.blueboard.cz'
    FTP_USER: 'ok1kvk.cz1'
  script:
    - node --version
    - rm -rf build
    - yarn
    - node ./index.js --prod
    - lftp --version
    - |
      lftp -e "debug 5
         set cmd:fail-exit yes;
         set net:timeout 5;
         set net:reconnect-interval-base 5;
         set net:max-retries 3;
         set ftp:ssl-force true;
         open --user $FTP_USER --env-password -p 21 ftp://$FTP_HOST/;
         mirror --verbose=3 --parallel=8 -c -R -L --no-perms --exclude=.htaccess ./build $FTP_DIR;
         exit 0;"

cache:
  paths:
    - node_modules/

