简体   繁体   English

如何使用Hubot将Github存储库部署到Heroku?

[英]How to use Hubot to deploy a Github repo to Heroku?

Back when they announced Hubot one of the things GitHub said they do with theirs is deployment. 当他们宣布 Hubot时,GitHub说他们对他们做的事情之一是部署。 I'm attempting to do the same for my project the code for which is hosted on GitHub while the app itself is on Heroku. 我正在尝试为我的项目执行相同的操作,其代码在GitHub上托管,而应用程序本身在Heroku上。 My Hubot also lives on Heroku but I'm doing all my testing locally first. 我的Hubot也住在Heroku上,但我首先在本地进行测试。

My idea was to either clone the target repo in tmp, add a remote in that repo to point to the Heroku app, then run git push heroku or (like this SO question ) create two remotes and push that way. 我的想法是在tmp中克隆目标repo,在该repo中添加一个遥控器指向Heroku应用程序,然后运行git push heroku或(像这样的SO问题 )创建两个遥控器并按此方式push While I've gotten the git clone to work locally when I try to run 当我尝试运行时,我已经让git clone在本地工作了

Exec "cd #{dir}; git remote add #{proj_loc} git@heroku.com:#{heroku_app}.git"

it ends up adding the remote to the git repo that exists in the directory from which I started bin/hubot not the git repo that now exists in tmp. 它最终将远程添加到git bin/hubotbin/hubot存在于我启动bin/hubot的目录中,而不是现在存在于tmp中的git bin/hubot I know dir is set correctly and that cd works because I've run 我知道dir设置正确并且cd工作因为我已经运行了

Exec "cd #{dir}; pwd"

and the results are what I'd expect. 结果是我所期待的。 So the behavior of git remote confuses me. 所以git remote的行为让我很困惑。

Has anyone done anything like this or can at least tell me why git remote doesn't add the remote to the temp in tmp and how to fix it? 有没有人做过这样的事情,或者至少可以告诉我为什么git remote不会将遥控器添加到tmp中的temp以及如何修复它?

I've also yet to try to tackle the issue of the keys required to 1) access a private repo on GitHub; 我还要尝试解决1)访问GitHub上的私人仓库所需的密钥问题; and 2) deploy to Heroku. 2)部署到Heroku。 I'll figure that out if I can get this working. 我会弄明白,如果我能让这个工作。

I did this with my system. 我用我的系统做了这个。 I had my hubot contact my build box via SSH and run the git pull / deploy command. 我让我的hubot通过SSH联系我的构建盒并运行git pull / deploy命令。 The deploy command would shoot a POST payload back to the hubot instance and all the statuses are posted to the hubot's chat client. deploy命令会将POST有效负载发送回hubot实例,并将所有状态发布到hubot的聊天客户端。 I wrote an entire blog post about it: http://tritarget.org/blog/2014/10/13/new-site-ship-it/ 我写了一篇关于它的完整博客文章: http//tritarget.org/blog/2014/10/13/new-site-ship-it/

I considered the same when I heard how Github were using Hubot. 当我听到Github如何使用Hubot时,我也是这么认为的。 At a guess though, they are hosting it on a machine that they manage, like a physical or a VPS which is much more like a local machine when it comes to deploying code. 但有人猜测,他们将它托管在他们管理的机器上,比如物理或VPS,在部署代码时更像是本地机器。 Whilst you may get bits working on Heroku I think you're going to struggle with keys and actually deployment - but I'm open to being proven wrong :) 虽然你可能会在Heroku上工作,但我认为你会在使用密钥和实际部署时遇到困难 - 但我很容易被证明是错误的:)

I created a Java / Play Framework app that might do what you want: 我创建了一个可能做你想要的Java / Play Framework应用程序:
https://github.com/heroku/shareheroku-java https://github.com/heroku/shareheroku-java

The app does the following: 该应用程序执行以下操作:

  1. Clones (or updates) a git repo from a git url 克隆(或更新)来自git url的git repo
  2. Creates a new ssh key for an existing Heroku user 为现有Heroku用户创建新的ssh密钥
  3. Adds the key to the user's account 将密钥添加到用户的帐户
  4. Ceates a new app on Heroku 在Heroku上创建一款新应用
  5. Pushes the cloned app to Heroku 将克隆的应用程序推送到Heroku
  6. Adds another user as a collaborator 添加另一个用户作为协作者
  7. Transfers ownership to the user 将所有权转让给用户
  8. Removes the original user from the app 从应用中删除原始用户
  9. Removes the ssh key from the original user 从原始用户删除ssh密钥

You can see it in action at: 您可以在以下位置看到它:
http://java.herokuapp.com http://java.herokuapp.com

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

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