|
1 |
| -# This is a basic workflow to help you get started with Actions |
| 1 | +name: Build and Deploy Docs |
2 | 2 |
|
3 |
| -name: Build and Deploy Github Pages |
4 |
| - |
5 |
| -# Controls when the workflow will run |
6 | 3 | on:
|
7 |
| - # Triggers the workflow on push or pull request events but only for the "main" branch |
8 | 4 | push:
|
9 |
| - branches: [ "main" ] |
| 5 | + branches: [ main ] # 或者您的默认分支名 |
10 | 6 | pull_request:
|
11 |
| - branches: [ "main" ] |
12 |
| - |
13 |
| -permissions: |
14 |
| - contents: read |
15 |
| - pages: write |
16 |
| - id-token: write |
| 7 | + branches: [ main ] |
17 | 8 |
|
18 |
| -# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
19 | 9 | jobs:
|
20 |
| - # This workflow contains a single job called "build" |
21 |
| - build_and_deploy: |
22 |
| - # The type of runner that the job will run on |
23 |
| - runs-on: ubuntu-latest |
24 |
| - |
25 |
| - # Steps represent a sequence of tasks that will be executed as part of the job |
| 10 | + build: |
| 11 | + runs-on: ubuntu-22.04 |
26 | 12 | steps:
|
27 |
| - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
28 |
| - - name: Checkout code |
29 |
| - uses: actions/checkout@v4 |
30 |
| - |
31 |
| - # Runs a single command using the runners shell |
32 |
| - - name: Set up Python |
33 |
| - uses: actions/setup-python@v5 |
34 |
| - with: |
35 |
| - python-version: '3.11' # 使用 .readthedocs.yaml 中指定的 Python 版本 |
36 |
| - |
37 |
| - - name: Build Sphinx Documentation |
38 |
| - run: make html |
39 |
| - working-directory: docs # 确保在 docs/ 目录中执行 make 命令 |
40 |
| - |
41 |
| - - name: Prepare Pages Artifact |
42 |
| - # 将构建好的 HTML 目录移动到一个标准名称,方便 upload-pages-artifact 使用 |
43 |
| - run: | |
44 |
| - mv docs/_build/html _site |
45 |
| -
|
46 |
| - - name: Upload Pages Artifact |
47 |
| - uses: actions/upload-pages-artifact@v3 |
48 |
| - with: |
49 |
| - path: _site # 上一步准备好的 Artifact 目录 |
50 |
| - |
51 |
| - - name: Deploy to GitHub Pages |
52 |
| - id: deployment |
53 |
| - uses: actions/deploy-pages@v4 |
54 |
| - |
| 13 | + - uses: actions/checkout@v3 |
| 14 | + - name: Set up Python |
| 15 | + uses: actions/setup-python@v4 |
| 16 | + with: |
| 17 | + python-version: '3.11' |
| 18 | + - name: Install dependencies |
| 19 | + run: | |
| 20 | + python -m pip install --upgrade pip |
| 21 | + pip install sphinx sphinx_book_theme myst-parser |
| 22 | + # 安装deepmodeling_sphinx |
| 23 | + if [ -f docs/requirements.txt ]; then pip install -r docs/requirements.txt; fi |
| 24 | + - name: Build docs |
| 25 | + run: | |
| 26 | + cd docs |
| 27 | + sphinx-build -b html . _build/html |
| 28 | + - name: Deploy |
| 29 | + uses: peaceiris/actions-gh-pages@v3 |
| 30 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 31 | + with: |
| 32 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 33 | + publish_dir: ./docs/_build/html |
0 commit comments