👷 cicd: 文档部署触发切换至main分支 #35
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: docs | |
on: | |
# 每当 push 到 main 分支时触发部署 | |
push: | |
branches: [main] | |
# 手动触发部署 | |
workflow_dispatch: | |
jobs: | |
docs: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout this | |
# @see https://github.com/actions/checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # 如果未启用 lastUpdated,则不需要 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Run install | |
# @see https://github.com/marketplace/actions/setup-pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 9 | |
run_install: | | |
- recursive: true | |
args: [--no-frozen-lockfile, --strict-peer-dependencies] | |
- args: [--global, gulp, prettier, typescript] | |
- name: Build Vite/VuePress site | |
run: pnpm docs:build | |
- name: Deploy to GitHub Pages | |
# @see https://github.com/crazy-max/ghaction-github-pages | |
uses: crazy-max/ghaction-github-pages@v2 | |
with: | |
# 部署到 gh-pages 分支 | |
target_branch: gh-pages | |
# 部署目录为 VuePress 的默认输出目录 | |
build_dir: docs/.vitepress/dist | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |