Github Pages

部署的过程全部在 Docker 容器内部进行,使用的镜像为 rahn2029/hexo-github


Hexo 部署

  1. 进入容器内部
  2. 配置 Github 账户信息
  3. 生成 SSH
  4. id_rsa.pub 内容复制到 Github
  5. 修改 hexo 根目录中的 _config.yml 文件,在最底部找到 deploy: ,填写如下内容(注意:冒号后面有个空格)
  6. 安装一键部署 hexo-deployer-git
  7. 清理临时文件、缓存,将生成的静态网站部署到 Github
1
2
3
4
5
6
7
8
9
10
11
12
13
14
docker exec -it hexo bash

git config --global user.name "18nome"
git config --global user.email "rainsky9527@proton.me"

ssh-keygen -t rsa -C "rainsky9527@proton.me"

cd /root/.ssh
ls
cat id_rsa.pub

cd /blog
ls
nano _config.yml
1
2
3
4
deploy:
type: 'git'
repo: 'git@github.com:18nome/18nome.github.io.git'
branch: master
1
2
3
4
5
npm install hexo-deployer-git --save
hexo clean
hexo generate
hexo deploy
exit

一键部署脚本

  1. 进入容器内部编写 hexo-deploy.sh 脚本
  2. 添加可执行权限后,退出容器
  3. 执行 docker exec -it hexo bash hexo-deploy.sh 完成部署
1
2
docker exec -it hexo bash
nano hexo-deploy.sh
1
2
3
hexo clean 
hexo generate
hexo deploy
1
2
chmod +x hexo-deploy.sh
exit
1
docker exec -it hexo bash hexo-deploy.sh

官方文档:https://hexo.io/zh-cn/docs/one-command-deployment.html