chore: 自动化部署文档 #1
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
on: | |
push: | |
branches: | |
- main | |
# 允许你从 Actions 选项卡手动运行此工作流程 | |
workflow_dispatch: | |
# 只允许同时进行一次部署,跳过正在运行和最新队列之间的运行队列 | |
# 但是,不要取消正在进行的运行,因为我们希望允许这些生产部署完成 | |
concurrency: | |
group: pages | |
cancel-in-progress: false | |
name: deploy-doc | |
jobs: | |
deploy-doc: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [21] | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Cache Node Modules | |
id: cache-node-modules | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Setup Pnpm | |
id: setup-pnpm | |
uses: pnpm/action-setup@v3 | |
- name: Install Dependencies | |
if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
run: pnpm install | |
- name: Build Site | |
run: pnpm docs:build | |
- name: Deploy Site | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./docs/.vitepress/dist | |
deploy_key: ${{ secrets.DEPLOY_KEY }} |