博客自动化部署
sonder 大杯

使用Github自动化部署

参考文章: https://juejin.cn/post/6943895271751286821

配置步骤

  1. 生成令牌 https://github.com/settings/tokens
  2. 在博客的仓库地址 https://github.com/xxx/xxxBlob/settings/secrets/actions 中新增/更新刚刚生成的令牌(该令牌可设置过期时间)
  3. 在hexo博客项目中找到.github => workflows => hexo-deploy.yml

注意:生成的令牌如果失效,那么push到分支后,将会打包失败,此时只需在第一步中找到该令牌,update之后,将新令牌也更新到第二步对应的secrets/actions即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
name: deploying Hexo project to GitHub pages
on:
push:
branches:
- main # master 分支有 push 行为时就触发这个 action 我这里改成了我分支名称 main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main

- name: Build and Deploy
uses: theme-keep/hexo-deploy-github-pages-action@master # 使用专门部署 Hexo 到 GitHub pages 的 action
env:
PERSONAL_TOKEN: ${{ secrets.HEXO_DEPLOY }} # secret 名 这个填写第二步新增时那个名称
PUBLISH_REPOSITORY: sonderss/xxx # 公共仓库,格式:GitHub 用户名/仓库名 这里就是博客静态文件所在仓库地址
BRANCH: gh-pages # 分支,填 gh-pages 就行
PUBLISH_DIR: ./public # 部署 public 目录下的文件
  • 本文标题:博客自动化部署
  • 本文作者:sonder
  • 创建时间:2022-09-24 16:30:33
  • 本文链接:https://sonderss.github.io/2022/09/24/博客自动化部署/
 评论