我想设置一个工作流程,能够将本地更改推送到 Bitbucket 或 Github(但最好是前者),然后更新我的 lamp VPS 服务器上托管的实时站点。这可能吗?我记得不久前与一个具有类似设置但使用 Github 的团队合作。
有一篇 Joe Maller 的文章 http://joemaller.com/990/a-web-focused-git-workflow/它描述了一种类似的方法,其中集线器是同一网络服务器上的另一个目录。
最佳答案
这种推送后操作是受管理的:
- 在 GitHub 上的 webhook (post-receive hook)
- 在 BitBucket 上使用 Service hooks如“broker”
更多信息请参见“POST hook management”。
在这两种情况下,这些 Hook 都会生成一个 POST Hook ,该 Hook 通过其 API 将有效负载传递给您的第三方 Web 应用程序。
您的第三方应用程序负责接收和转换有效负载。
这意味着您的 Lamp VPS 服务器需要有一个能够解释所述有效负载的监听器。
您可以看到管理部署的脚本示例 in this article ,通过执行 git pull
:
// Make sure we're in the right directory
exec('cd '.$this->_directory, $output);
$this->log('Changing working directory... '.implode(' ', $output));
// Discard any changes to tracked files since our last deploy
exec('git reset --hard HEAD', $output);
$this->log('Reseting repository... '.implode(' ', $output));
// Update the local repository
exec('git pull '.$this->_remote.' '.$this->_branch, $output);
$this->log('Pulling in changes... '.implode(' ', $output));
关于从本地到 bitbucket/github hub 再到实时网络服务器的 Git 工作流程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20076599/