This repository was archived by the owner on Mar 16, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (129 loc) · 5.29 KB
/
docs.yml
File metadata and controls
145 lines (129 loc) · 5.29 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Deploy docs to GitHub Pages (hivemind.rithul.dev)
# - On push to main: deploy "latest" from current main
# - On release published: deploy versioned docs from tag (e.g. 1.2.0)
#
# Required: Repo Settings → Pages → Build and deployment → Source:
# "Deploy from a branch" → Branch: gh-pages → / (root)
# (This workflow pushes to gh-pages; it does not use the "GitHub Actions" deploy source.)
name: Docs
on:
push:
branches: [main]
paths:
- ".github/workflows/docs.yml"
- "docs/**"
- "mkdocs.yml"
- "pyproject.toml"
- "requirements-docs.txt"
- "branding/**"
release:
types: [published]
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: docs
cancel-in-progress: false
jobs:
deploy-latest:
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install docs dependencies
run: pip install -r requirements-docs.txt
- name: Get version
id: version
run: |
V=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
echo "version=$V" >> $GITHUB_OUTPUT
- name: Deploy latest to gh-pages
run: |
set -e
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Give mike a local gh-pages synced with remote so push is not rejected (remote may have CNAME from prior run)
git fetch origin gh-pages 2>/dev/null || true
if git show-ref -q refs/remotes/origin/gh-pages; then
git checkout -B gh-pages origin/gh-pages
git checkout -
fi
# Suppress Material's MkDocs 2.0 warning (we pin mkdocs<2)
run_filtered() {
set +e
out=$("$@" 2>&1)
s=$?
set -e
echo "$out" | grep -v -E "MkDocs 2\.0|backward-incompatible|plugin system|theming system|No migration path|Closed contribution|Currently unlicensed|Our full analysis|squidfunk\.github\.io/mkdocs-material/blog" || true
return $s
}
run_filtered mike deploy --push --allow-empty --update-aliases "${{ steps.version.outputs.version }}" latest
run_filtered mike set-default --push --allow-empty latest
- name: Ensure CNAME on gh-pages
run: |
git clone --branch gh-pages "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" gh-pages-out
cd gh-pages-out
echo "hivemind.rithul.dev" > CNAME
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add CNAME
git diff --staged --quiet || (git commit -m "chore(docs): ensure CNAME for custom domain" && git push)
deploy-version:
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install docs dependencies
run: pip install -r requirements-docs.txt
- name: Parse version from tag
id: version
run: |
V="${GITHUB_REF#refs/tags/v}"
echo "version=$V" >> $GITHUB_OUTPUT
- name: Deploy versioned docs to gh-pages
run: |
set -e
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Give mike a local gh-pages synced with remote so push is not rejected
git fetch origin gh-pages 2>/dev/null || true
if git show-ref -q refs/remotes/origin/gh-pages; then
git checkout -B gh-pages origin/gh-pages
git checkout -
fi
# Suppress Material's MkDocs 2.0 warning (we pin mkdocs<2)
run_filtered() {
set +e
out=$("$@" 2>&1)
s=$?
set -e
echo "$out" | grep -v -E "MkDocs 2\.0|backward-incompatible|plugin system|theming system|No migration path|Closed contribution|Currently unlicensed|Our full analysis|squidfunk\.github\.io/mkdocs-material/blog" || true
return $s
}
run_filtered mike deploy --push --allow-empty "${{ steps.version.outputs.version }}"
run_filtered mike alias --push --allow-empty "${{ steps.version.outputs.version }}" stable
- name: Ensure CNAME on gh-pages
run: |
git clone --branch gh-pages "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" gh-pages-out
cd gh-pages-out
echo "hivemind.rithul.dev" > CNAME
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add CNAME
git diff --staged --quiet || (git commit -m "chore(docs): ensure CNAME for custom domain" && git push)