-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (73 loc) · 3.1 KB
/
deploy-mkdocs.yml
File metadata and controls
91 lines (73 loc) · 3.1 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
89
90
91
# ============================================================
# .github/workflows/deploy-docs.yml (Deploy MkDocs)
# ============================================================
# SOURCE: https://github.com/denisecase/templates
#
# WHY-FILE: Build and deploy documentation to GitHub Pages on pushes to main.
# REQ: Repo Settings -> Pages -> Build and deployment -> Source:
# GitHub Actions
name: Docs Deploy (MkDocs)
on:
push:
branches: [main] # WHY: Run when pushing to main branch.
workflow_dispatch: # WHY: Allow manual triggering from Actions tab.
permissions:
contents: read # WHY: Needed to checkout code.
pages: write # WHY: Required to deploy to GitHub Pages.
id-token: write # WHY: Required by deploy-pages for OIDC.
env:
PYTHONUNBUFFERED: "1" # WHY: Real-time logging.
PYTHONIOENCODING: "utf-8" # WHY: Ensure UTF-8 encoding for international characters.
concurrency:
# WHY: Only one Pages deployment at a time per branch.
group: pages-${{ github.ref }}
cancel-in-progress: true
jobs:
docs:
name: Deploy MkDocs documentation site
runs-on: ubuntu-latest
timeout-minutes: 30 # WHY: Prevent hanging jobs. If over, it is likely stuck.
steps:
# ============================================================
# ASSEMBLE: Get code and set up environment
# ============================================================
- name: A1) Checkout repository code
# WHY: Needed to access files for checks.
uses: actions/checkout@v6
- name: A2) Configure GitHub Pages
# WHY: Sets Pages metadata for deployments.
uses: actions/configure-pages@v5
- name: A3) Install uv (with caching)
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: A4) Install Python version 3.14
run: uv python install 3.14
- name: A5) Sync to install dependencies
run: uv sync --extra dev --extra docs --upgrade
# ============================================================
# BASELINE CHECKS: Fail fast and validate
# ============================================================
- name: B1) Fail fast if no MkDocs configuration
run: |
if [ -f "mkdocs.yml" ] || [ -f "mkdocs.yaml" ]; then
echo "MkDocs configuration found. Proceeding."
else
echo "ERROR: mkdocs.yml not found."
echo "If you do not want documentation deployment,"
echo "delete .github/workflows/deploy-docs.yml (or add mkdocs.yml)."
exit 1
fi
# ============================================================
# === DEPLOY: Build and deploy ===
# ============================================================
- name: D1) Build docs (mkdocs --strict)
run: uv run mkdocs build --strict --verbose
- name: D2) Upload Pages artifact
# WHY: Package the built site for Pages deployment.
uses: actions/upload-pages-artifact@v4
with:
path: site
- name: D3) Deploy to GitHub Pages
# WHY: Publish artifact to GitHub Pages.
uses: actions/deploy-pages@v4