Automated .gitlab-ci.yml lftp configuration

半城伤御伤魂 提交于 2019-12-03 08:43:07

You can use :

lftp -u username,passwd ftp.foobar.cmo \
     -e "mirror -e -R -x .git -x static/ -p ./ dev-site ; quit"

Where, in mirror :

  • -e : remove files that doesn't exist anymore
  • -R : means you upload from local machine to ftp server
  • -x : specify a directory to exlude. You can have more than one -x
  • -p : parallelize
  • ./ : local dir you want upload
  • dev-site : remote dir where upload have to go. Take care about the remote dir parameter :
    • if it end with a trail (dev-site/), your current dir will be uploaded INSIDE this dir on the ftp server
    • if it doesn't end with a trail (dev-site), your current dir will be uploaded AS this dir on the ftp server

If yout to use this with GitLab CI to upload your static-generated documentation, here is an example .gitlab-ci.yml with mkdocs + lftp:

# Build static html site with mkdocs :
build:
  stage: build
  script:
  - mkdocs build
 # first upload, exclude static files:
  - lftp -u ftp_username,$FTP_PASSWORD ftp.foobar.org -e "mirror -x static -R -p site dev ; quit"
 # upload only static to other server:
 - lftp -u ftp_username,$FTP_PASSWORD ftp.otherserv.org -e "mirror -R -p static/ remote/dir ; quit"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!