内容提要
由于个人博客是放在Gitea里面的,如果每次写好博文,都要生成一次静态页面并发布到服务器上,显然过于繁琐,因此本文介绍了如何结合Drone实现博文的自动生成和发布工作。
- Gitead的安装配置请参考我的博文: docker安装gitea并启用https访问
- Drone的安装与配置请参考我的博文: DRONE安装与配置
hugo配置
修改Hugo项目根目录下的config.toml文件。主要是修改网站URL,主题等。
baseURL = "http://blog.xxx.com/"
theme = "anatole"
buildDrafts = true
Drone配置
在项目根目录下创建.drone.yml文件,加入如下配置。
kind: pipeline
name: default
clone:
skip_verify: true
steps:
- name: build
image: plugins/hugo
commands:
- git clone https://github.com/lxndrblz/anatole.git themes/anatole
- hugo --config config.toml
- name: publish
image: appleboy/drone-scp
settings:
host: blog.xxx.com
username: {username} #登录用户
password:
from_secret: ssh_xxx_password #登录密码,从drone的加密文件中读取,最好不要写明码
port: 22
target: /usr/share/nginx/html/blog.xxx.com
source: public
OK,一切就绪,commit并push到gitea,然后就可以在drone中看到网站自动构建并发布了,是不是很香??
评论区