Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proper continuous integration and continuous deployment with Git and Heroku

I am developing a ruby on rails website using heroku and git.

What tools and features should I use to set up the following simple development process?

CODE > CHECK-IN > AUTO TEST > AUTO DEPLOY

  • I check my code into my repository (preferred option, hosted git like github)
  • Tests are automatically run AND website is deployed in my staging heroku app
  • If tests pass, the website is automatically deployed on my production heroku app
  • If tests fail, I want to be notified somehow.

How would you do this?

like image 410
Aymeric Avatar asked Jun 27 '10 11:06

Aymeric


People also ask

Does Heroku have continuous deployment?

Heroku provides a variety of continuous delivery tools to help you deploy effortlessly and safely: Pipelines make it easy to maintain separate staging and production environments for your app. Review apps let you try out a GitHub pull request's changes in an isolated and disposable environment.

What is continuous integration in Heroku?

Heroku CI builds the code and deploys to a temporary app. Parallel test runs and results are shared in a visual interface. Parallel test runs and results are shared in a visual interface. Manually fix and push the code, tests re-run automatically. Manually fix and push the code, tests re-run automatically.

Is Heroku integrated with Git?

Heroku integrates with GitHub to make it easy to deploy code living on GitHub to apps running on Heroku. When GitHub integration is configured for a Heroku app, Heroku can automatically build and release (if the build is successful) pushes to the specified GitHub repo.

How does Heroku work with Git?

Git is a powerful, distributed version control system that many developers use to manage and version source code. The Heroku platform uses Git as the primary means for deploying applications (there are other ways to transport your source code to Heroku, including via an API).


2 Answers

CircleCi offers exactly what you need. We'll run your tests on every push, deploy them if they pass (to Heroku or using Capistrano/Fabric/anything really), and send you notifications if they fail.

like image 157
Paul Biggar Avatar answered Oct 15 '22 21:10

Paul Biggar


to preface I am one of the founders of Codeship (https://codeship.io), which is a service that supports exactly this.

But more on topic, basically there are 2 different ways I think this could be implemented (please keep in mind that all branch names I use are arbitrary and can be named totally different):

staging/production in one go

Whenever you push to your master or a specific deploy branch you run your tests and if all of them pass you first deploy to your staging app, run separate tests (Selenium or sauce labs is great for that) and if that works out including migrations you push to your production app.

This is great as the latest version is always available in production and we use this cycle for a long time now. Works great for us. The downside is that pushing to a staging heroku app takes some time. If you want to run the migrations against a copy of your production data this takes even more time. It's not an eternity, but it takes a couple of minutes.

staging/production as separate steps

You could have separate staging/production branches which are deployed to the respective heroku applications. This has the advantage of being faster and you can control when to release certain parts. Especially for applications where you want external feedback before deploying to production this works great.

We support all of that at Railsonfire, but we are currently working on a new version of our service which is way better. We integrate really well with Heroku so you don't have to think about that (but still have the option to do it yourself in any way you want)

like image 32
Florian Motlik Avatar answered Oct 15 '22 23:10

Florian Motlik