S
S
Siricks122017-03-11 18:13:38
git
Siricks12, 2017-03-11 18:13:38

How to properly delete files when deploying a project through Gitlab CI?

Task: to organize updating sites on remote servers after a commit
How it is implemented now:
A post-receive hook has been created for the project. When I commit to the corresponding branch, the files are checked out to the local directory:

git --work-tree=/var/www/test.com --git-dir=/var/opt/gitlab/git-data/repositories/test/test-project.git/ clean -fd
git --work-tree=/var/www/test.com --git-dir=/var/opt/gitlab/git-data/repositories/test/test-project.git/ checkout -f

If everything is fine (tests passed), a runner is launched in Gitlab, which does:
lftp -e "mirror --delete --exclude \public_html/config.php --exclude \.gitlab-ci.yaml --exclude \public_html/img/. -R /var/www/test.com / ; quit;" -u ftp-user,ftp-password ftp://xxx.xxx.x.xxx:21

The catch is deleting files. Now, if I deleted some file from the project, it is first deleted from the folder where the site is deployed locally (/var/www/test.com), and then from the remote server. But at the same time, if the remote server has its own files that are not in the Git project, lftp also deletes them, which should not be.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Siricks12, 2017-03-15
@Siricks12

git-ftp push -u -p - ftp://ftp.example.com

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question