Hexo 使用 Github Actions 自动更新
准备
- 需要两个 github 仓库:
- 一个用于发布页面: XXXXXX.github.io
- 一个用于放源码: hexo-source (可设为隐私仓库)
1. 创建 hexo-source 仓库
- 在hexo的根目录下( ~/hexo)运行:
1
2
3
4
5
6
7
8cd hexo
git init
git add .
git commit -m "first commit"
git remote add origin https://github.com/XXXXXX/hexo-source.git
git push -u origin master
2. Github Actions 设置
运行 ssh-keygen 生成一对密钥。
1
ssh-keygen
打开 XXXXXX.github.io 仓库设置,在
Deploye keys
选项中,添加公钥~/.ssh/id_rsa.pub
的内容。打开 hexo-source 仓库设置,在
Secrets
选项中,新建 repo secret: 名称设为GITHUB_ACTION
, 内容为~/.ssh/id_rsa
的内容。
3. 添加 Github Actions 配置文件
内容如下:
1 |
|
以上。