75 lines
1.5 KiB
YAML
75 lines
1.5 KiB
YAML
name: 部署文档
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'docs/**'
|
|
- 'openapi.json'
|
|
- 'package.json'
|
|
- 'pnpm-lock.yaml'
|
|
- '.github/workflows/deploy-docs.yml'
|
|
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
pages: write
|
|
id-token: write
|
|
|
|
concurrency:
|
|
group: pages-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
# 构建作业
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
|
|
|
|
steps:
|
|
- name: 检出代码
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: 设置pnpm
|
|
uses: pnpm/action-setup@v2
|
|
with:
|
|
version: 9
|
|
|
|
- name: 安装依赖
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: 复制OpenAPI文件到public目录
|
|
run: |
|
|
mkdir -p docs/public
|
|
cp openapi.json docs/public/
|
|
|
|
- name: 构建文档
|
|
run: pnpm docs:build
|
|
env:
|
|
NODE_ENV: production
|
|
|
|
- name: 设置Pages
|
|
uses: actions/configure-pages@v4
|
|
|
|
- name: 上传构建产物
|
|
uses: actions/upload-pages-artifact@v3
|
|
with:
|
|
path: docs/.vitepress/dist
|
|
|
|
# 部署作业
|
|
deploy:
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
|
|
|
|
steps:
|
|
- name: 部署到GitHub Pages
|
|
id: deployment
|
|
uses: actions/deploy-pages@v4 |