Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails3 & Git & Heroku - development/staging server

I have a Rails 3 app I'm developing with a team using Git/Github and deploying to a Heroku cedar stack. Our Github respository has 2 main branches Master and Development.

I would like to push our Development branch regularly to a different server on Heroku as a development/staging environment.

What's the cleanest simplest way to push our Development branch to a different app than Master without disrupting our Git flow much?

Thanks a lot!

like image 448
tuddy Avatar asked Feb 23 '23 14:02

tuddy


2 Answers

You'll want to add a second git remote i.e. your second application's heroku git repo url to your app to be able to push to that from a single codebase.

At the moment you probably have the default remote origin named 'heroku' which is pushing to your production application.

You'll want to add a second remote origin pointing at your new heroku app that you intend to use for staging, eg

git remote add staging <git repo url from 'my apps' page on heroku>

once you have the new git origin set up you can push to it via;

git push staging <branch to deploy>:master
like image 192
John Beynon Avatar answered Feb 26 '23 19:02

John Beynon


Simple. Heroku always uses the master branch, but using Git will allow you to push /your/ development branch, to /their/ master

For instance:

git push heroku development:master

where heroku is your origin for your heroku development env, and development is your local development branch. You might also want to override the RACK_ENV var on Heroku too if you don't want your dev branch running in production mode (although, personally I would create a staging environment in your code which does caching etc, but not send email to production addresses etc)

like image 37
Neil Middleton Avatar answered Feb 26 '23 21:02

Neil Middleton