当我尝试将存储库中的代码部署到服务器上的生产目录时,就会出现问题。
根据cpanel documentation about deployment,要进行部署,git存储库必须包含一个.cpanel.yml
文件,该文件已提交以下示例数据:
---
deployment:
tasks:
- export DEPLOYPATH=/home/user/public_html/
- /bin/cp index.html $DEPLOYPATH
- /bin/cp style.css $DEPLOYPATH
我尝试了此文件的各种不同配置,以便能够进行部署,但无法使其正常工作。我找不到更多文档或任何进一步的开发示例或示例文件。
我的linux服务器的相关结构如下:
home/<username>/
- git/gitrepo/
- all of the git files and folders
- public_html/<app_folder>/
我想将git存储库中的所有文件和文件夹部署到public_html/<app_folder>/
目录中。
我尝试了以下不同的配置:
---
deployment:
tasks:
- export DEPLOYPATH=/home/<username>/public_html/<app_folder>
- / $DEPLOYPATH
---
deployment:
tasks:
- export DEPLOYPATH=/home/user/public_html/
- /bin/cp $DEPLOYPATH
---
deployment:
tasks:
- export DEPLOYPATH=/home/user/public_html/
- / index.html $DEPLOYPATH // Tried just one file to see if would work but it didn't.
---
deployment:
tasks:
- export DEPLOYPATH=/home/user/public_html/
- /bin/cp index.html $DEPLOYPATH // Tried just one file to see if would work but it didn't.
答案 0 :(得分:6)
因此,这基本上是一个bash脚本,当您更新存储在服务器上的存储库时,CPanel将运行该脚本。您的情况下的布局应为:
如果您要复制示例,否则可能会删除所有“#条评论”
---
deployment:
tasks:
- export DEPLOYPATH=/home/<username>/public_html/<app_folder>
- /bin/cp <file_name> $DEPLOYPATH #Copy specific file to destination from root
- /bin/cp /<sub_folder>/<file_name> $DEPLOYPATH #copy specific file from source sub folder
- /bin cp * $DEPLOYPATH #copy all from root
- /bin cp /<sub_folder>/* $DEPLOYPATH #copy all from sub folder root
因此以上内容对您来说都适用。
如果您要把整个根都做到目的地,那么这里就是我用来复制所有根的那个。
---
deployment:
tasks:
- export DEPLOYPATH=/home/<user_name>/public_html #Add /<sub_folder> if required
- /bin/cp -r * $DEPLOYPATH
如果您需要除public_html以外的应用程序文件夹,请记住添加/<sub_folder>
您可以从我的仓库中获取文件:
https://github.com/FrancoisGeyser/cPanel-yml.git
希望有帮助。