Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.2k views
in Technique[技术] by (71.8m points)

wordpress - Deploy Raw Source Code from GitLab Repository

I have a Gitlab repository containing a WordPress theme - php, js, and css files. My desired result is that when I push a change to the 'main' branch of the repo, the theme files are deployed, raw, without any build or test steps, to my remote server.

I have a .gitlab-ci.yml file set up with 'deploy' as its only step.

The script triggers on 'only: -main' and successfully accesses my remote server via ssh.

What I'm unsure of is how to send the entire raw repository to the remote.

Here is the 'script' portion of my yml:

- rsync -rav --delete project-name/ /var/opt/gitlab/git-data/repositories/project-name/ username@my.ip.add.ress:public_html/wp-site/wp-content/themes/

When the pipeline runs, I receive the following two errors:

rsync: [sender] change_dir "/builds/username/project-name/project-name" failed: No such file or directory (2)

rsync: [sender] change_dir "/var/opt/gitlab/git-data/repositories/project-name" failed: No such file or directory (2)

Is GitLab looking in /builds/ its default behavior? I am not instructing it to do so in my yml.

Is there some other file path I should be using to access the working tree for 'main' in my repository?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Ok, I misunderstood the rsync syntax. I thought the --delete flag included a parameter thereafter, meaning 'delete any existing files in the following directory' rather than what it actually does, which is to auto-choose the destination directory. Once I removed 'project-name/' and corrected the GitLab (origin) file path to '/builds/username/project-name/' the deployment occurs as intended.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...