Introduction
As this blog is no longer hosted on GitHub Pages, I needed a quick and lite way to perform continuous deployment on a Web server.
Available on my new Gitea instance, I thought about webhooks at first.
On the other hand, I didn’t want to deploy a webhook server dedicated to static deployment, nor a CI/CD solution (as Drone) for this specific need.
So this is a short write-up (only) about SSH, Bash scripts and Jekyll usage, if you want to achieve something similar.
Here, I assume that your Gitea instance and your Web server are running separately.
The procedure
On the Gitea container
Before anything else, impersonate the git
user and generate a key pair to allow SSH authentication on the Web server :
Now you’ll have to add a new hook to your repository settings.
Modify the below script to fit your needs, and add it as a post-receive
hook :
On the Web server
Open a root
shell on your Web server and let’s generate a deploy key for the www-data
user, allowing it to pull from the Gitea repository :
Now you can go to your Gitea repository settings, and add the new deploy key generated :
Still as www-data
, you can try your deploy key at this moment :
Finally, you will also need a new script (/path/to/deployment.sh
) :
Don’t forget to :
Finally, you’ll have to authorize the remote git
user (the one likely running Gitea) to execute the script above with a specific argument (/root/.ssh/authorized_keys
), set the public key copied at the first step of this guide :
Conclusion
As always, improvements are welcome below !
And guess what ? This blog post has been automatically deployed