Deploying to Heroku from Gitlab

code, devops, CI/CD, heroku, gitlab

Having a continues deployment to Heroku from Gitlab is hidden away, previous solutions I've found require putting in docker acrobatics into your .gitlab-ci.yml and a rest endpoint; but no more! The solution is simple for most projects.

Master is Prod

Leveraging the Gitlab repo mirror tool for only protected branches we can just provide the login for Heroku and we're done! The steps below give more detail:

  1. Install the Heroku cli
  2. Generate an access token
  3. Set up repo mirroring from your project to http://user@git.heroku.com/your-app.git
    • The username is ignored
    • The password is your access token
  4. And were done, pushes to master should mirror into Heroku, build and deploy automagically!