如何在推送时自动部署我的 git repo 的子模块? [英] How can I auto-deploy my git repo's submodules on push?

查看:28
本文介绍了如何在推送时自动部署我的 git repo 的子模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正常运行的 PHP Cartridge,但我找不到一种直接的方法让 OpenShift 在推送我的核心 repo 文件时/之后(递归地)推送我的 git 子模块的文件.

I have a PHP Cartridge that is operating normally, except I can't find a straightforward way to get OpenShift to (recursively) push the files for my git submodules when/after it pushes my core repo files.

这看起来应该是一个超级简单且常见的用例.我是不是忽略了什么?

This seems like it should be a super straightforward and common use-case. Am I overlooking something?

我可能可以 ssh 进入我的服务器并手动拉取它们,但我想完全自动化,这样如果我在我的 repo 中更新子模块的引用,这些更改将在我部署.

I could probably ssh into my server and pull them manually, but I'd like to automate this completely, so that if I update the submodule's reference in my repo these changes will be reflected when I deploy.

推荐答案

好的,我会加分 50 分 ;)

Ok, I'll take a stab at this for 50 extra points ;)

以下是我遵循的步骤:

1.) 在克隆到本地机器上的 OpenShift 上创建 php-5.3 应用程序.
2.) 在 github 上创建公共 git 存储库以用作子模块.
3.) 使用以下命令将 github 存储库添加到 OpenShift 应用程序中,确保使用 https url 而不是 git@ url,否则当 OpenShift Online 尝试检出子模块时,您会遇到私钥问题.

1.) Create php-5.3 application on OpenShift on clone to local machine.
2.) Create public git repository on github to use as the submodule.
3.) Add the github repository to the OpenShift application using the following commands, make sure that you use the https url instead of the git@ url, or you will get private key issues when OpenShift Online tries to checkout the sub-module.

 cd into your locally cloned openshift application directory  
 git submodule add https://github.com/developercorey/somesubmodule.git ./directory_name
 git add .
 git commit -am "adding a submodule"
 git push

如果您在 git push 中没有看到任何错误,那么一切都应该正常运行.如果你看到这样的错误

If you don't see any errors in your git push, then everything should have worked correctly. if you see an error like this

remote: Host key verification failed.
remote: fatal: Could not read from remote repository.
remote: 
remote: Please make sure you have the correct access rights
remote: and the repository exists.

这意味着您使用 git@ url 而不是 https url 来添加您的 git 子模块,或者您正在尝试访问私有存储库.现在您可以使用 rhc ssh 命令 ssh 进入您的应用程序,然后 cd 进入您的 ~/app-root/runtime/repo 目录,您应该会在那里看到您的子模块目录,其中包含该存储库中的文件.

That means you used the git@ url instead of the https url to add your git submodule, or you are trying to access a private repository. Now you can ssh into your application using the rhc ssh command and cd into your ~/app-root/runtime/repo directory and you should see your submodule directory there with the files from that repository inside.

如果这对您不起作用,请告诉我您的 git push 的输出是什么,我们将从那里开始.

If that doesn't work for you, please let me know what the output of your git push is and we'll go from there.

这篇关于如何在推送时自动部署我的 git repo 的子模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆