[英]Conditional path to deploy in cpanel.yml file configuration
I need to deploy the same repository in different paths based on the current path of this file我需要根据这个文件的当前路径在不同的路径中部署同一个仓库
Example:例子:
If this .Cpanel.yml is in the repository located at "/ home / foo / repository / foo_prod /" , implement it at / home / foo / public_html / production_folder / but if the file location binder .如果此.Cpanel.yml在位于“/home/foo/repository/foo_prod/”的存储库中,则在/home/foo/public_html/production_folder/中实现它,但如果文件位置为 binder . cpanel.yml is in "/ home / foo / repository / foo_pre_prod /" so implement it in / home / foo / public_html / pre_prod_folder /
cpanel.yml在“/home/foo/repository/foo_pre_prod/”所以实现在/home/foo/public_html/pre_prod_folder/
Current file.cpanel.yml当前文件.cpanel.yml
---
deployment:
tasks:
- export DEPLOYPATH=/home/foo/public_html/xyz/
- /bin/cp -R * $DEPLOYPATH
Maybe try something like this:也许尝试这样的事情:
deployment:
tasks:
- current_branch=$(git branch --show-current) # set current branch to variable
- if [ $current_branch == "master" ]; then export DEPLOYPATH=/home/foo/public_html/xyz/; fi;
- if [ $current_branch == "develop" ]; then export DEPLOYPATH=/home/foo/public_html/xyz_dev/; fi;
- /bin/cp -R * $DEPLOYPATH
Solved my previous question.
解决了我之前的问题。 I share what I did.
我分享我所做的。 Thanks @Salines your anwer help me!
谢谢@Salines,你的回答对我有帮助!
---
deployment:
tasks:
- current_path=`pwd` # set current path to variable
- if [ $current_path == "/home/user/repositories/p" ]; then export DEPLOYPATH=/home/user/public_html/p/; fi;
- if [ $current_path == "/home/user/repositories/p_pre" ]; then export DEPLOYPATH=/home/user/public_html/p_pre/; fi;
- /bin/cp -R * $DEPLOYPATH
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.