I'm running this site on a 5$ pr month DigitalOcean server.
I first tried out their new Apps / serverless setup, where you merely specify your Github project to be deployed and the required build commands. Worked like a charm.
This is - however - a 6$ pr app pr month solution, and yes, I'm that cheap 😆 ... I do plan to add multiple sites to this single server.
Anyways, I soon realized that my static site setup required more git pulling than I had hoped for, so decided to configure automatic deployment with a Github webhook.
In PHP you could do something like:
// TODO: Handle secret from Github
if ( $_POST['payload'] ) {
shell_exec('cd /path/to/your/site && git pull');
}
However, you need to allow Apache to perform the update:
sudo usermod -s /bin/bash www-data
sudo su - www-data
ssh-keygen
Then upload the public key to Github.
It's incredibly fast! After doing a push, I see the change on the site in less than 5 seconds! 😲
shell_exec()
?Me neither ... 😅
Got a better way to do it? Please let me know in the comments.