73 lines
1.8 KiB
YAML
73 lines
1.8 KiB
YAML
name: 文档站
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- 'docs/**'
|
|
- 'README.md'
|
|
- 'README.en.md'
|
|
- '.github/workflows/docs.yml'
|
|
pull_request:
|
|
paths:
|
|
- 'docs/**'
|
|
- 'README.md'
|
|
- 'README.en.md'
|
|
- '.github/workflows/docs.yml'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: docs-${{ github.ref }}
|
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
|
|
jobs:
|
|
build:
|
|
name: 文档检查与构建
|
|
runs-on: ubuntu-24.04
|
|
defaults:
|
|
run:
|
|
working-directory: docs
|
|
steps:
|
|
- name: 检出代码
|
|
uses: actions/checkout@v7
|
|
with:
|
|
fetch-depth: 0
|
|
- name: 安装 Node.js
|
|
uses: actions/setup-node@v7
|
|
with:
|
|
node-version: 24
|
|
cache: npm
|
|
cache-dependency-path: docs/package-lock.json
|
|
- name: 安装文档依赖
|
|
run: npm ci --ignore-scripts
|
|
- name: 检查链接转换与 Markdown 渲染
|
|
run: npm test
|
|
- name: 构建静态站点
|
|
run: npm run build
|
|
- name: 上传 Pages 构建产物
|
|
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
|
|
uses: actions/upload-pages-artifact@v3
|
|
with:
|
|
path: docs/.vitepress/dist
|
|
|
|
deploy:
|
|
name: 发布到 GitHub Pages
|
|
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
|
|
needs: build
|
|
runs-on: ubuntu-24.04
|
|
permissions:
|
|
pages: write
|
|
id-token: write
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
steps:
|
|
- name: 检查 Pages 配置
|
|
uses: actions/configure-pages@v5
|
|
- name: 发布静态站点
|
|
id: deployment
|
|
uses: actions/deploy-pages@v4
|