Category: gitlab

This tutorial is going to go over how to auto-deploy your code to Heroku automatically whenever you push to your main GitLab branch. Also, in your GitLab project CI / CD settings, add a new variable HEROKU_API_KEY with the value of your personal API key from your Heroku account settings. This key will allow GitLab CI / CD to manage your Heroku account so be careful who has access to your project! Now you can copy and paste the below .gitlab-ci.yml file in your root project folder: The build-frontend task is optional to deploy to Heroku, but I thought it was an interesting method of bundling your frontend code static files to serve from your API on deployment.

This task initializes a new git repo in the root code folder of the API project, sets the remote to the Heroku project git repo and pushes the code.

Related Articles