With Semaphore it's very easy to set up continuous deployment of applications hosted on Heroku. You only need to make sure that you have a configured application on Heroku and a corresponding project on Semaphore.
To get started, find your desired project and follow "Set Up Deployment" link under branches list.
This will launch a simple 5-step process.
The first step is to select Heroku as your deployment method.
There are two deployment strategies on Semaphore: "automatic" and "manual".
Automatic means that a deploy will be triggered after every passed build on the selected branch. Besides that, you can also manually deploy any build from any branch at any time.
Manual strategy requires manual selection of builds to deploy.
For automatic deployment you will be asked to select which branch will be automatically deployed after each passed build.
Note: You can easily change the deployment strategy from server settings at any time after the setup is complete.
At this point you need to paste your Heroku API key. You can find it under account information on the Heroku dashboard.
By providing your Heroku API key, you authorize Semaphore to configure and set SSH keys that are needed for deployment.
After you select your application from the list, Semaphore will generate and set new pair of SSH keys for you:
This means that Semaphore will set up everything that you need for deployment on Heroku, including Heroku toolbelt which allows you to run any Heroku command during deployment.
In this step you need to provide a name for your server, which can be any name you like. It will be used on your Semaphore dashboard and deployment timeline. During this step, you may also choose to set a server URL for quick access to wherever you are deploying your application.
Each server has its own alias which represents server's name in a safe string form. The alias is also available in the deploy environment via SEMAPHORE_SERVER_NAME environment variable.
By now the setup is complete - you are ready to deploy to Heroku.
If your application requires some additional deploy commands (such as running migrations after deploy) you can edit the default commands by editing the related server on the server page for your project.
Heroku toolbelt doesn't propagate exit status codes by default. This may result in a failed deploy to be reported as passed. A common example is the failure of a db:migrate task. This is because for Semaphore a command has failed if its exit status code is != 0 (zero means success).
To make a Heroku command propagate the exit code up to Semaphore, use the --exit-code option: heroku run --exit-code -- COMMAND. For example, the following command will correctly report the exit code of a database migration in Rails.
heroku run --exit-code -- bundle exec rake db:migrate
See the heroku help run command for more details.
Semaphore Docs are open source — Edit on GitHub