|
1 | | -name: docs |
| 1 | +name: Documentation |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - tags: |
6 | | - - "v*.*.*" |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - "docs/**" |
| 8 | + - "scripts/prepare_gitbook_site.py" |
| 9 | + - "scripts/check_docs.py" |
| 10 | + - ".gitbook.yaml" |
| 11 | + - "Justfile" |
| 12 | + - ".github/workflows/docs.yml" |
| 13 | + pull_request: |
| 14 | + paths: |
| 15 | + - "docs/**" |
| 16 | + - "scripts/prepare_gitbook_site.py" |
| 17 | + - "scripts/check_docs.py" |
| 18 | + - ".gitbook.yaml" |
| 19 | + - "Justfile" |
| 20 | + - ".github/workflows/docs.yml" |
7 | 21 | workflow_dispatch: |
8 | 22 |
|
9 | | -permissions: |
10 | | - contents: write |
11 | | - |
12 | 23 | jobs: |
13 | | - deploy: |
| 24 | + docs: |
| 25 | + permissions: |
| 26 | + contents: write |
14 | 27 | runs-on: ubuntu-latest |
15 | 28 | steps: |
16 | | - - uses: actions/checkout@v4 |
| 29 | + - name: Check out the repository |
| 30 | + uses: actions/checkout@v4 |
17 | 31 | with: |
18 | | - fetch-depth: 0 # <-- required so tags + full history are present |
19 | | - |
20 | | - - name: Configure Git Credentials |
21 | | - run: | |
22 | | - git config user.name github-actions[bot] |
23 | | - git config user.email 41898282+github-actions[bot]@users.noreply.github.com |
| 32 | + fetch-depth: 0 |
24 | 33 |
|
25 | 34 | - uses: actions/setup-python@v5 |
26 | 35 | with: |
27 | | - python-version: 3.x |
| 36 | + python-version: "3.13" |
28 | 37 |
|
29 | | - - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV |
30 | | - - uses: actions/cache@v4 |
31 | | - with: |
32 | | - key: mkdocs-material-${{ env.cache_id }} |
33 | | - path: ~/.cache |
| 38 | + - name: Install uv |
| 39 | + run: python -m pip install uv |
34 | 40 |
|
35 | | - restore-keys: | |
36 | | - mkdocs-material- |
| 41 | + - name: Sync Python dependencies |
| 42 | + run: uv sync --locked |
37 | 43 |
|
38 | | - - name: Install dependencies |
39 | | - run: | |
40 | | - pip install uv |
| 44 | + - name: Check documentation links |
| 45 | + run: uv run python scripts/check_docs.py |
41 | 46 |
|
42 | | - - name: Build & Deploy |
| 47 | + - name: Build GitBook site |
| 48 | + run: uv run python scripts/prepare_gitbook_site.py |
| 49 | + |
| 50 | + - name: Deploy to gitbook-docs branch |
| 51 | + if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} |
43 | 52 | run: | |
44 | | - uv run --group docs mkdocs gh-deploy --force |
| 53 | + git config user.name 'github-actions[bot]' |
| 54 | + git config user.email 'github-actions[bot]@users.noreply.github.com' |
| 55 | +
|
| 56 | + mv site/ /tmp/gitbook-site/ |
| 57 | +
|
| 58 | + git fetch origin gitbook-docs || true |
| 59 | + if git rev-parse --verify origin/gitbook-docs >/dev/null 2>&1; then |
| 60 | + git checkout gitbook-docs |
| 61 | + else |
| 62 | + git checkout --orphan gitbook-docs |
| 63 | + git rm -rf . |
| 64 | + fi |
| 65 | +
|
| 66 | + rsync -a --delete --exclude='.git' /tmp/gitbook-site/ . |
| 67 | + git add -A |
| 68 | + if ! git diff --cached --quiet; then |
| 69 | + git commit -m "docs: update GitBook documentation from ${{ github.sha }}" |
| 70 | + git push origin gitbook-docs |
| 71 | + fi |
0 commit comments