VitePress Github Deploy
yml
name: Deploy VitePress Docs
on:
workflow_dispatch: {}
# master 发生 push 时触发部署
push:
branches:
- vitepress
jobs:
build-and-deploy:
name: Deploy VitePress Docs
# 指定运行机器
runs-on: ubuntu-latest
# 执行步骤
steps:
# 检出仓库
- name: git checkout & git pull
uses: actions/checkout@v3 #https://github.com/actions/checkout
with:
fetch-depth: 0
# 安装 Node.js
- name: Install Node.js
uses: actions/setup-node@v3 #https://github.com/actions/setup-node
with:
node-version: '16.19.0'
cache: npm
cache-dependency-path: ./vitepress
# 安装依赖
- name: Install dependencies
run: cd ./vitepress && npm ci
# 构建文档
- name: Build
run: cd ./vitepress && npm run docs:build
# 部署到 GitHub Pages
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3 # https://github.com/peaceiris/actions-gh-pages
with:
personal_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: ./vitepress/docs/.vitepress/dist
destination_dir: ./vitepress
keep_files: true
在 Deploy to GitHub Pages
时出现 Permission to XXX.git denied to github-actions[bot].
的错误
解决方法
在 github 当前项目的仓库中,进入 Settings > Actions > General
目录下
- 将
Workflow permissions
下的default permissions granted
设置为Read and write permissions
- 勾选
Allow GitHub Actions to create and approve pull requests