Using Gitlab to deploy using FTP

The aim is for modications on a project’s master branch to be deployed across to a server using the SFTP protocol. A limitation of this particular set-up is that it requires gitlab-runner to be running locally on your machine to process the task.

Prerequisites

gitlab-ci.yml

stages:
  - deploy
  
publishToMaster:
  stage: deploy
  script:
    - lftp -e "mirror --reverse --exclude ^\.git.* --exclude \.gitlab-ci.yaml -eRv  $CI_PROJECT_DIR ./; quit;" sftp://$SFTP_CREDENTIALS/$DEPLOY_DESTINATION
  tags:
    - local

In your project’s > Settings > Pipeline make sure to create values for SFTP_CREDENTIALS and DEPLOY_DESTINATION.

Reading

How to deploy your static website easily with gitlab