- 在Github新建博客仓库,用于存放提交的源码。
-
设置仓库的公钥和私钥
生成命令ssh-keygen -t rsa -C youremail@example.com
- 在github创建actions,配置代码如下
name: blog deploy
on:
push:
branches:
- master
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: npm ci
- run: npm install vuepress
- run: npm run build
- run: cp CNAME docs/.vuepress/dist/
- name: Deploy
uses: peaceiris/actions-gh-pages@v2.5.0
env:
ACTIONS_DEPLOY_KEY: ${{secrets.key}}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: docs/.vuepress/dist
- cp CNAME docs/.vuepress/dist/ 是配置解析域名的,可以去掉。
- key是你的仓库私钥名
当你在本地更新完博客,直接提交并推送到Github项目,Actions就会在云端自动打包并部署到gh-pages分支,就可以直接用 github用户名.github.io/项目名 的方式访问了。
我的博客项目地址:https://github.com/shanghaobo/qinyu-blog
我的博客地址:https://qinyushop.com/
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。