简体   繁体   English

使用Capistrano在部署时修改文件

[英]Modifying files at deployment with Capistrano

I've got a PHP project that uses Capistrano 3 to deploy to staging/testing/live and everything works fine. 我有一个PHP项目,该项目使用Capistrano 3进行部署以进行阶段/测试/实时运行,并且一切正常。

Now we've encountered a bug in one of our dependencies that are included through PHPComposer, it's really an easy fix (change one line) which we do manually in the vendor directory on our development boxes, just until the bug is fixed through our pull request. 现在,我们在PHPComposer中包含的一个依赖项中遇到了一个错误,这确实是一个简单的修复(更改一行),我们可以在开发盒的vendor目录中手动进行此操作,直到该错误通过我们的拉动被修复为止。请求。 But every time we deploy all dependencies are installed again on the deployment target server including the bugged dependency. 但是,每次我们部署时,所有依赖项都会重新安装在部署目标服务器上,包括错误的依赖项。 After we manually ssh into the server and change that one line in the particular file the deploy is successful. 手动将SSH SSH到服务器并在特定文件中更改该行之后,部署成功。

How would I go about automating this with capistrano? 我将如何使用capistrano自动化它? Are there proven ways of doing this? 有行之有效的方法吗?

I suspect the 'official' solution to this is to fork the repo with your fix in place, and then alias the new repo, setting your composer.json to use that in preference to the original while you wait for the fix to be merged upstream. 我怀疑对此的“官方”解决方案是在存储库已修复的情况下分叉存储库,然后为新存储库添加别名,将composer.json设置为在等待上游合并修补程序时优先使用原始存储库。 。

There are some details on the Composer site - require-inline-alias Composer网站上有一些详细信息-require -inline-alias

The composer.json configuration to be able to do the inline-aliasing is: 能够进行内联别名的composer.json配置为:

"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/you/monolog"
    }
],
"require": {
    "symfony/monolog-bundle": "2.0",
    "monolog/monolog": "dev-bugfix as 1.0.x-dev"
}

That will fetch the dev-bugfix version of monolog/monolog from your GitHub and alias it to 1.0.x-dev. 这将从您的GitHub获取monolog / monolog的dev-bugfix版本,并将其别名为1.0.x-dev。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM