简体   繁体   English

在 cpanel.yml 文件配置中部署的条件路径

[英]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.

相关问题 尝试将 cpanel git 存储库部署到目录时 .cpanel.yml 文件的格式问题。 - Issues with the format of .cpanel.yml file when trying to deploy cpanel git repository to directory. 无法确定默认配置路径。 在 cloudflared Linux 中没有文件 [config.yml config.yaml] - Cannot determine default configuration path. No file [config.yml config.yaml] in cloudflared Linux greenplum gpload:配置YML文件错误 - greenplum gpload : configuration YML file error 我想用该文件中的另一个路径替换 yml 文件中的路径 - i want to replace a path inside a yml file with another path in that file 如何在prometheus yml 配置文件中配置特定IP? - How to configure a specific IP in prometheus yml configuration file? 如何在configuration.yml文件中配置电子邮件设置 - How to configure email settings in configuration.yml file 如何从cpanel帐户下载文件到另一个cpanel帐户 - how to download file from cpanel account to another cpanel account Godaddy Imagick Path配置 - Godaddy Imagick Path configuration 致命:目标路径'/ var / cpanel / easy / apache / custom_opt_mods / Cpanel已存在,并且不是空目录 - fatal: destination path '/var/cpanel/easy/apache/custom_opt_mods/Cpanel already exists and is not an empty directory 保存 gcc 的文件在哪里,并在 Linux Mint 上进行配置,包含标题的路径? - Where is located a file keeping gcc, and make configuration on Linux Mint, path to include headers?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM