37

I have a github repo that I want to push to a heroku node. A 3rd host will be co-ordinating this. As I'm going to be doing this on a large scale I want to avoid having to download the contents of the repo onto the 3rd host. How do I do it?

1

4 Answers 4

47

You can't push straight from Github to Heroku.

You're going to have to use the third host to coordinate the push. This could be fired from a Github post-receive hook.

To sync straight across use something like:

git remote add github [email protected]:user/repo.git
git remote add heroku [email protected]:app.git

git push heroku refs/remotes/github/master:refs/heads/master
3
  • I've already got that working. It does look like there isn't going to be any way to avoid using the filesystem on the 3rd host :(
    – opsb
    Jul 31, 2010 at 16:18
  • 4
    Not quite the answer I was looking for, but probably the most useful for people looking at this question.
    – opsb
    Sep 18, 2010 at 11:44
  • 3
    I went with a simpler setup: create a github repo, clone it locally, add heroku as remote, then just git push heroku master. Jul 18, 2013 at 23:57
2

Codeship.io does this as a service now, and automatically configures the appropriate git webhooks on public or private github repos.

There are a few other "continuous integration as a service" (CIAAS) options out there, but in general they get around the problem you're specifically presenting: web hooks need to hit a 3rd-party service, which in turn can trigger the heroku build process.

These CIAAS hosts act as the 3rd-party, and usually offer a free tier for public projects. You can also roll your own by deploying a web hook receiving server, which can both pull and push git repos.

2
  • Codeship is actually free for 5 private repos; up to 100 deploys a month. I'm probably going to give it a try.
    – Rob Grant
    Aug 6, 2014 at 8:49
  • Actually I'm not; they don't support Python 3.x. But still, very cool.
    – Rob Grant
    Aug 6, 2014 at 8:53
0

I don't think you can push directly from GitHub to another remote repo.

So if you have many apps to push, you may consider an organization using submodules, like in this SO question.

You would still have to download a repo to push it on the Heroku node, but at least you can control what to pull/push (and do some cleaning between each push).

1
  • I won't actually be the owner of the apps(I'm building a cloud based service) so I won't have control over how they are organised.
    – opsb
    Jul 25, 2010 at 6:02
0

About a year after my previous answer about codeship.io, Heroku launched the beginnings of their Pipeline feature set, which includes proper Github integration.

https://devcenter.heroku.com/articles/github-integration

The whole pipeline flow is really powerful, allowing for temporary instances based on branches, multiple app deployments, staging->production promotion, etc. More information can be found on Heroku's overview article.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.