Skip to content

Commit e7ea984

Browse files
committed
Add automated docs deployment with GitHub Actions
1 parent 6318ea6 commit e7ea984

2 files changed

Lines changed: 83 additions & 0 deletions

File tree

.github/workflows/deploy-docs.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Deploy MkDocs Documentation
2+
3+
on:
4+
push:
5+
branches: [ master ] # 当推送到master分支时触发
6+
paths:
7+
- 'docs/**'
8+
- 'mkdocs.yml'
9+
- '.github/workflows/deploy-docs.yml'
10+
pull_request:
11+
branches: [ master ]
12+
paths:
13+
- 'docs/**'
14+
- 'mkdocs.yml'
15+
16+
permissions:
17+
contents: read
18+
pages: write
19+
id-token: write
20+
21+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
22+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
23+
concurrency:
24+
group: "pages"
25+
cancel-in-progress: false
26+
27+
jobs:
28+
# Build job
29+
build:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 0
36+
37+
- name: Setup Python
38+
uses: actions/setup-python@v4
39+
with:
40+
python-version: '3.x'
41+
42+
- name: Cache dependencies
43+
uses: actions/cache@v3
44+
with:
45+
path: ~/.cache/pip
46+
key: ${{ runner.os }}-pip-${{ hashFiles('docs/requirements.txt') }}
47+
restore-keys: |
48+
${{ runner.os }}-pip-
49+
50+
- name: Install dependencies
51+
run: |
52+
python -m pip install --upgrade pip
53+
pip install -r docs/requirements.txt
54+
55+
- name: Setup Pages
56+
uses: actions/configure-pages@v3
57+
58+
- name: Build with MkDocs
59+
run: |
60+
mkdocs build --verbose --strict
61+
62+
- name: Upload artifact
63+
uses: actions/upload-pages-artifact@v2
64+
with:
65+
path: ./site
66+
67+
# Deployment job
68+
deploy:
69+
environment:
70+
name: github-pages
71+
url: ${{ steps.deployment.outputs.page_url }}
72+
runs-on: ubuntu-latest
73+
needs: build
74+
if: github.ref == 'refs/heads/master'
75+
steps:
76+
- name: Deploy to GitHub Pages
77+
id: deployment
78+
uses: actions/deploy-pages@v2

docs/requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
mkdocs>=1.5.0
2+
mkdocs-material>=9.0.0
3+
mkdocstrings[python]>=0.23.0
4+
pymdown-extensions>=10.0.0
5+
mkdocs-mermaid2-plugin>=1.0.0

0 commit comments

Comments
 (0)