How to create review apps in Heroku from Gitlab

A review app is a temporary application created to help you review in-progress code changes. You’ll use a review app because you’re working on a code branch and want to see what the changes will be like in a production-like environment, or because you’re reviewing a pull or merge request from someone else.

Gitlab doesn’t explicitly outline how to setup review apps with Heroku, but the Heroku API is well-documented, and it’s quite straightforward to get this up and running. You’ll need to set up a few environment variables. And make sure that the length of your branch name and your project name is no greater than 29 characters (heroku has an app name length limit).

To create a review app:

  1. The interesting things happen inside (Inside start_review_scripts.bash)
  2. Create a new app with a URL derived from the name of the code branch
  3. Get the right git branch, then push it to heroku.

YAML section on creating a review app in heroku via its API

To delete the review app:

  1. Delete the app

code snippet to stop review app. Use the hyperlink to access the full snippet

View this build pipeline in full.

Leave a comment

Your email address will not be published. Required fields are marked *