mirror of
https://github.com/Awuqing/BackupX.git
synced 2026-08-28 19:47:27 +08:00
81 lines
1.8 KiB
YAML
81 lines
1.8 KiB
YAML
name: Deploy Docs
|
|
|
|
# 触发条件:
|
|
# - PR 修改 docs-site/ 时执行类型检查和构建
|
|
# - 推送 main 时构建并部署 GitHub Pages
|
|
# - 手动触发(在 Actions 页面)
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'docs-site/**'
|
|
- '.github/workflows/docs.yml'
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'docs-site/**'
|
|
- '.github/workflows/docs.yml'
|
|
workflow_dispatch:
|
|
|
|
# 默认只读;Pages 写权限仅授予部署任务。
|
|
permissions:
|
|
contents: read
|
|
|
|
# 同一分支只保留最新一次构建,避免旧提交覆盖新结果。
|
|
concurrency:
|
|
group: docs-${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build:
|
|
name: Build Docs
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
defaults:
|
|
run:
|
|
working-directory: docs-site
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '24'
|
|
cache: 'npm'
|
|
cache-dependency-path: docs-site/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Type check
|
|
run: npm run typecheck
|
|
|
|
- name: Build site
|
|
run: npm run build
|
|
|
|
- name: Upload artifact
|
|
if: github.event_name != 'pull_request'
|
|
uses: actions/upload-pages-artifact@v3
|
|
with:
|
|
path: docs-site/build
|
|
|
|
deploy:
|
|
name: Deploy Docs
|
|
if: github.event_name != 'pull_request'
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
permissions:
|
|
pages: write
|
|
id-token: write
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
steps:
|
|
- name: Deploy to GitHub Pages
|
|
id: deployment
|
|
uses: actions/deploy-pages@v4
|