Setting up continuous deployment for my site

By Santiago Forero on October 10 2021

Hello, in today’s post I will show you how I managed to set up continuous deployment to my site.

Before I explain anything, I want to tell you how was my workflow when I changed anything in my site:

  1. Make local changes
  2. Commit and push to the remote git repo
  3. SSH into my server
  4. Pull from the remote repo
  5. Execute the build command

Doing this manually doesn’t really take much time, however, it’s fancier to do this automatically.

In the beginning, I was thinking about setting up a GitHub Action that basically accessed my server via SSH and executed the build commands, this isn’t a really safe approach because I’m giving direct access to my machine even with an unprivileged user, I spent some time researching and asking in the ##github IRC channel in Libera, someone suggested me to use webhooks, which mean that GitHub would make a post request to a specified endpoint, I decided that this was my best option so I started searching for services I could host in my machine, I found several options and I couldn’t decide which one, so I made my own! A really simple node script that created an express web server that listened for post requests in some (very) secret endpoints and executed a small deploy script automatically when reached. This worked amazingly well in the first attempt. Now if I want to make changes to my computer I don’t even need my computer! I can use GitHub’s web editor to do anything and the changes are live almost instantly.

Thank you for reading my post, let me know what you think and if you have ever done something like this.