Preview deploy with Coolify with Pull Request
Netlify has been great. But I don't want to depend on that too much. Currently, you can use 300 minutes Netlify goodness for free. After that, it will cost a whopping $19 per month to use the platform. No, thank you. Instead, I set up Coolify and a GitHub action to accomplish the same benefits.
What is Netlify Anyway? (for me) #
I used Netlify for the following benefits:
-
Deploying my website. Netlify can build a website for you and host it there. You can manage a domain name.
-
Deployment previews for pull requests: When I open a pull request on GitHub, I want to preview the app. Netlify can create a preview for you and comment on that pull request with a pretty message:
Why I want to move away from Netlify #
SaaS like Netlify can change their mind anytime. In 2018, users used to get 100 hours of run time. In 2024, it's down to 6 hours. Maybe in the future, we will get none---who knows.
I want to avoid being at Netlify's mercy; that's why I set up to accomplish the same benefits, using a different way.
Coolify & GitHub Action #
I have a virtual private server (VPS) running on Hetzner, and there I run my Coolify instance. Coolify is an open-source Netlify replacement in a nutshell. I like it because it gives me things to click around on via the GUI.
On Coolify, I can deploy websites, including this one. So, I can take care of the Benefit No. 1 about deploying by using Coolify.
To accomplish Benefit No. 2 about deploy previews, I took two-step approach.
Step 1: Coolify GitHub Integration #
I connected Coolify with my GitHub repo (Coolify > Integration). This integration does Preview Deployments: each Pull Request will trigger a new preview deployment.
But, this is not enough—I want a message on my Pull Request with a link to the Preview Deploy. To do so, I set up a GitHub action.
Step 2: Pull Request Comment #
I created a GitHub Action, which uses Comment Pull Request Action.
Coolify uses a Pull Request number to produce a predictable Preview Deployments URL (e.g., pr100-blog.namisunami.com). So, I set up a message something like blow:
- message: |
Preview deployment available at https://pr{{ github.event.number }}-blog.namisunami.com
In Pull Request, the GitHub Actions bot will send a message:
The message is not as pretty as Netlify's message, but it works for me to check the preview of the page before merging to the main.