Heroku, deploy!

Deploying to Heroku is straightforward. Making your continuous integration works is okay. Using your continuous integration to deploy to Heroku is… managable.

In this post, I will narrate about how I make our supreme application to be auto-deployed to heroku whenever we commit something to a branch (develop or master).

Why Heroku?

Because we are told to do so. Heroku is one of the most popular container-based cloud Platform as a Service (PaaS). So… what is PaaS? Basically Heroku provide platform where you can deploy your app and have your friends access them through internet.

Design is part of Heroku’s DNA, it’s at the heart of everything we do. We approach our work using the guiding principles of utility, simplicity, elegance, and quality. Every single person at Heroku sweats the details and contributes to the Heroku experience.

Using Heroku is very simple for developers. Heroku not only provides GUI interface through their website,  they also provide CLI. As a developer, of course using CLI is nice and intuitive (I’m not being sarcastic here, seriously).

Deploying your apps!

There are many ways to deploy app to Heroku, one of them is using dpl. dpl is a deploy tool written in Ruby, specifically made for continuous deployment (though, you can also use it to deploy them in your development machine a.k.a Laptop).

Using dpl is very straightforward. First, you need to install dpl with gem.

gem install dpl

Then, from the root of your project directory, run dpl from your shell

$ dpl --provider=heroku --app=$HEROKU_APP_NAME --api-key=$HEROKU_API_KEY

Wait for some moments, and voila! your app is ready and deployed

Integrating deployment with Gitlab-CI

In order to automatically update your deployed application with the latest code, we can use Continuous Integration to do that. So, when you commit or merge your branch to a specific branch (e.g. master, develop, etc.), your latest code will be automatically deployed to Heroku.

Assumed that you already know how to play around with GitLab-CI, and already know what is .gitlab-ci.yml. In order to auto-deploy your apps using CI is is pretty much the same as deploying them from your laptop.


Create a job, in stage deploy, and run the necessary script in that job. In summary, put this in your .gitlab-ci.yml

deploy to staging:
  stage: deploy
    - gem install dpl
    - dpl --provider=heroku --app=$HEROKU_APP_STAGING_NAME --api-key=$HEROKU_API_KEY
    name: staging
    - develop

In the script above, a job named “deploy to staging” is created. The job run exactly the same command we previously discussed.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s