GitHub Actions (and GitHub) plus Heroku is a match made in heaven

I build Python projects & host the source code on GitHub repositories quite often. And thanks to GitHub Actions, I needn’t worry about Continuous Integration needs either. While Heroku takes care of my Continuous Deployment needs.

But, there’s a problem. Heroku doesn’t provide a straightforward way to deploy the project using GitHub Actions. I need to download Heroku CLI to do it instead.

And if you’ve been reading my articles, you would know I’m quite a minimalist. I don’t like adding more bloatware & extra dependencies to my development machine than what’s needed. Hence, I had to look out for an alternative.

My current development process is to commit changes on my local machine & then push it to remote. The remote here is usually a GitHub repo with GitHub Actions configured to trigger a suite of tests. And if everything passes, deploy the project to production. Pretty standard practice & nothing fancy over here.

But the caveat is Heroku CLI uses git commands to push code to Heroku’s remote. So, it’s pretty much like pushing code to a GitHub repository. But, with no robust CI/CD pipelines. I could configure Heroku to deploy when the tests pass On GitHub. But it’s best to stick to standard practice & configure everything under one roof.

Also, invoking git commands on a remote machine doesn’t sound like a good idea. So, I felt sharing the techniques I use to circumvent this tricky situation was the right thing to do.

So, we’ll be using GitHub Actions to configure a CI/CD pipeline. And, FastAPI to build our hypothetical REST API.

And, without further adieu, let’s dive in & learn how to do it.

#heroku #github-actions #python #fastapi #github

Using GitHub Actions to Deploy a FastAPI Project to Heroku
4.90 GEEK