Ram Rachum
Ram Rachum

Reputation: 88598

Git proxy that pushes to multiple remotes

I'm looking for a piece of software that I hope someone has built. I'm going to describe this software here hoping that someone heard about something like this and can point me in the right direction.

I'm developing a web app which is deployed on Heroku. Because of Heroku's limitations, I am being put in the unfortunate situation of having four (4) remote Git repos for the same repos.

Why four?

We have multiple "apps" on Heroku. One for production and a couple of staging "apps". These are all for the same actual app, but on Heroku they are separate "apps", so we could try things out on staging before pushing them to production.

Each app on Heroku gets its own separate Git repo, and automatically deploys the master branch every time a new commit is pushed to that master branch. This policy of Heroku is the crux of our problem. Because this means that we have 3 different repos on Heroku, plus our GitHub repo.

Why is it a problem having 4 different Git remotes? Because it means that when you develop and create new commits, you have to either (1) push to only one remote or (2) push to all remotes.

Doing (1) means thinking which remote you'd like to push to. I hate having to think about this. When I develop, I don't care about the remotes, I commit and push and get back to work. If I want to deploy a branch into staging server 1, for example, I would merge that branch into the staging_1 branch and push it. I don't like picking which remote to push to.

Another disadvantage of (1) is that your remotes go out of sync.

What I want is (2). I want every push action to push to all of our four repos.

But there are 2 problems with that:

Problem 1: The staging "apps" on Heroku deploy what's on master. I don't want them to do that. I want to map the staging_1 branch in my repo to the master branch on the staging server Git repo.

Problem 2: Having my computer push to all 4 repos will take a long time. Even 1 Heroku push action takes a long time. It can take 40 seconds sometimes.


Proposed solution

Here's what I want. I want to have a specialized Git server that acts as a proxy. Whenever I push from my local computer into this Git server, it'll push those same branches into our 4 repos in parallel. In that way, from my local computer's perspective, the push will seem instantaneous, while this proxy server will automatically deal with the Heroku repos in the background.

If the push to any of the 4 remotes fails for any reason, I want this proxy to report back in some way so I'll know something is broken and could fix it.

Another thing that this proxy will have to do is the master mapping. Every time I would push the staging_1 branch to it, it'll push it as staging_1 to all the remotes, but to the remote belonging to the staging server it will also push that branch as master, so Heroku will know to deploy it.

(It's pretty sad that Heroku is designed in a way that makes me need a proxy like this, but that's what I have to deal with.)

So that's it. That's the solution I want. Does anyone know of such a program?

Upvotes: 6

Views: 438

Answers (2)

Andrew Aylett
Andrew Aylett

Reputation: 40720

Create a new repository, which you can push to when you want the push to propagate, and write a post-receive hook to propagate the changes when you push into this repo.

Upvotes: 1

Neil Middleton
Neil Middleton

Reputation: 22238

This seems a little crazy to me. I have multiple apps on Heroku that run differing environments. I have one Github repo and then the Heroku remotes for the differing environments. I also tend to maintain a Git branch which matches one of the Heroku remotes.

Deployments are then done (as John says) with:

git push heroku_remote local_branch:master

I've documented this basic approach here:

http://neilmiddleton.com/deploying-topic-branches-to-heroku/

However, you have the need for complete automation from what I can tell. You can use a service such as TDDium to do this sort of thing for you, watching a Git branch and then pushing to a remote branch (such as a Heroku remote) when your test suite passes.

http://neilmiddleton.com/continuous-deployment-with-heroku/

I'm pretty sure the TDDium approach will give you what you need, with the additional layer of CI.

Upvotes: 0

Related Questions