Automatic Hugo blog deploy with Gitea and Drone
Today I will tell how my blog posts automatically deployed with one only git push
command.
Hugo is a generator which build static site from text files. Since everything is text, version control system such as Git is a great choice for data storage.
Using hooks, we can trigger any actions after source code modification. In this case, when we make command git push
, changes are pushing to self-hosted source code hosting system, where push
web hook executed. This web hook give command to Drone to build the site.
Gitea
On my server I have installed source code hosting system Gitea. Gitea — is lightweight free and open Git service.
Earlier I have an expirience with Gitlab, that was like voracious monster doing to many extra moves. Gitea compared to it is very handy quick tool.
Drone
Drone — free continious delivery system. Drone works flowlessly with Gitea, easy to configure and doens‘t need much of system resources.
To make it work we need to create pipeline file in the root of our repo: .drone.yml
. Documentation contains detailed instructions on how to use it.
My configuration for deploying blog on hosting:
|
|
There is only one docker pipeline based on alpine
.
- 11: before build we need to pull every git submodule, if there is one;
- 22-29: configuring ssh connection with web hosting which is used to host Hugo build result files;
- 30: installing necessary executable files;
- 31: setting up npm dependencies;
- 32: building site;
- 33: copying result to web hosting;
- 35-45: send notification about build result with telegram bot.