I’ve created a very minimalistc repository to show, how to deploy Go code to Heroku using GitLab CI.
Automatically triggered on push/merge:
Create a new Heroku Pipeline.
Set up as many Heroku apps in this pipeline as you need (e.g. staging and production).
git clonethis repository or copy whatever you need.
Get your Heroku API key found in your account.
Set the key as the variable
HEROKU_API_KEYin your GitLab CI / CD Settings.
.gitlab-ci.ymland change the existing app name (
-app=gitlab-heroku-deploy-*) to your newly created apps.
- Heroku uses the $PORT environment variable (see
In this setup, Heroku knows what to deploy based on the modified
Gopkg.toml(see buildpack for alternatives)
[metadata.heroku] root-package = "gitlab.com/sj14/go-heroku"
- Inspired by Stacy Goh: Setting up CI/CD on Gitlab (using node)
- GitLab CI/CD Examples
- Also inspiring and more complete, using a Makefile but without Heroku: Go tools and GitLab: How to do continuous integration like a boss