-
Notifications
You must be signed in to change notification settings - Fork 10
88 lines (76 loc) · 2.48 KB
/
Copy pathdocs.yml
File metadata and controls
88 lines (76 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Documentation
on:
push:
branches: [main]
paths:
- "docs/**"
- "theme_overrides/**"
- "sphinx_docs/**"
- "src/**"
- "mkdocs.yml"
- ".readthedocs.yml"
- "requirements-docs.txt"
- "pyproject.toml"
- "setup.py"
- ".github/workflows/docs.yml"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: docs-publish
cancel-in-progress: false
jobs:
docs:
runs-on: ubuntu-latest
env:
DOC_SITE_REPO: INFTY-AI/doc
DOC_SITE_BRANCH: main
DOC_REPO_TOKEN: ${{ secrets.DOC_REPO_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip
cache-dependency-path: requirements-docs.txt
- name: Install documentation dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements-docs.txt
- name: Build MkDocs site
run: |
rm -rf docs/sphinx/_build
mkdocs build --strict
- name: Build Sphinx API docs
run: sphinx-build -b html sphinx_docs build/sphinx/html
- name: Skip external publish when token is missing
if: ${{ env.DOC_REPO_TOKEN == '' }}
run: echo "DOC_REPO_TOKEN is not configured; built docs locally but skipped publish to ${DOC_SITE_REPO}."
- name: Checkout documentation site repository
if: ${{ env.DOC_REPO_TOKEN != '' }}
uses: actions/checkout@v4
with:
repository: ${{ env.DOC_SITE_REPO }}
ref: ${{ env.DOC_SITE_BRANCH }}
token: ${{ env.DOC_REPO_TOKEN }}
path: doc-site
- name: Sync built site into documentation site repository
if: ${{ env.DOC_REPO_TOKEN != '' }}
run: |
touch site/.nojekyll
rsync -av --delete --exclude '.git/' site/ doc-site/
- name: Commit and push published site
if: ${{ env.DOC_REPO_TOKEN != '' }}
working-directory: doc-site
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
if git diff --cached --quiet; then
echo "No site changes to publish."
exit 0
fi
git commit -m "docs: publish from ${GITHUB_REPOSITORY}@${GITHUB_SHA}"
git push origin HEAD:${DOC_SITE_BRANCH}