Repository navigation
206 lines (187 loc) · 8.03 KB
/
Copy pathdocs.yml
File metadata and controls
206 lines (187 loc) · 8.03 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Builds and publishes the MkDocs documentation site (`docs/public`) and the
# Astro preview site (`docs/site`, published under `/preview/`).
#
# On a pull request that touches docs sources, it runs a build-only check for
# both sites to catch errors without publishing. On a push to `main`, it builds
# both sites, stages the Astro output into `site/preview/`, and deploys to
# GitHub Pages via `ghp-import`. Before building, it copies the
# specification schemas into the docs tree (flattening versioned JSON to the
# version root for clean URLs) and converts GitHub-style admonitions to the
# MkDocs format. Runs only on the upstream `a2ui-project/a2ui` repository.
name: Docs
on:
push:
branches:
- main
paths:
- ".github/workflows/docs.yml"
- ".github/actions/setup-python/**"
- "requirements-docs.txt"
- "pyproject.toml"
- "lychee.toml"
- "mkdocs.yaml"
- "hooks.py"
- "specification/**"
- "catalogs/**"
- "docs/**"
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name || github.ref }}
cancel-in-progress: true
jobs:
changes:
if: github.repository == 'a2ui-project/a2ui'
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
docs: ${{ steps.filter.outputs.docs }}
steps:
- name: Checkout Code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Check for docs changes
uses: dorny/paths-filter@0e4a8c6effa4802afeda77dc8d303f8176d7dfad # v3
id: filter
with:
# An empty token makes the action diff `pull_request.base.sha..HEAD`
# with git instead of reading the pull request's files from the
# GitHub API, which fails the job when the API has a transient
# error. It fetches the base commit itself, so the shallow checkout
# above is enough. Push and scheduled runs always used git.
token: ""
filters: |
docs:
- ".github/workflows/docs.yml"
- ".github/actions/setup-python/**"
- "requirements-docs.txt"
- "pyproject.toml"
- "mkdocs.yaml"
- "hooks.py"
- "lychee.toml"
- "specification/**"
- "catalogs/**"
- "docs/**"
- "**.md"
build_and_deploy:
needs: changes
if: github.repository == 'a2ui-project/a2ui' && (github.event_name == 'push' || needs.changes.outputs.docs == 'true')
runs-on: ubuntu-latest
# Requires write access to publish built documentation to gh-pages branch
permissions:
contents: write
actions: read
env:
# Root package.json declares yarn as packageManager; allow standalone npm in docs/site.
COREPACK_ENABLE_STRICT: "0"
steps:
- name: Checkout Code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
persist-credentials: ${{ github.event_name == 'push' }}
- name: Configure Git Credentials
if: github.event_name == 'push'
run: |
git config --global user.name github-actions[bot]
git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com
- name: Setup Python
uses: ./.github/actions/setup-python
with:
python-version: "3.13"
- name: Install documentation dependencies
run: |
uv venv
uv pip install -r requirements-docs.txt
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "22"
cache: "npm"
cache-dependency-path: "docs/site/package-lock.json"
- name: Install preview site dependencies
run: npm --prefix docs/site ci || npm --prefix docs/site install --no-package-lock
- name: Validate documentation conversion script
run: uv run pytest docs/scripts/test_convert_docs.py
- name: Copy schemas to documentation
run: |
mkdir -p docs/public/specification/
cp -R specification/* docs/public/specification/
# Catalogs live in the top-level catalogs/ directory but are published
# under specification/<version>/catalogs/ so that catalog $id URLs
# (e.g. https://a2ui.org/specification/v1_0/catalogs/basic/catalog.json)
# keep resolving.
mkdir -p docs/public/specification/v1_0/catalogs/basic
cp catalogs/basic/v1/catalog.json docs/public/specification/v1_0/catalogs/basic/
cp -R catalogs/basic/v1/examples docs/public/specification/v1_0/catalogs/basic/
# The MCP catalog v1 targets protocol v1.0.
mkdir -p docs/public/specification/v1_0/catalogs/mcp
cp catalogs/mcp/v1/catalog.json docs/public/specification/v1_0/catalogs/mcp/
cp -R catalogs/mcp/v1/examples docs/public/specification/v1_0/catalogs/mcp/
# Flatten JSON files to version roots to support clean URLs without redirects
for version in v0_8 v0_9 v0_9_1 v1_0; do
if [ -d "docs/public/specification/$version/json" ]; then
cp docs/public/specification/$version/json/*.json docs/public/specification/$version/
fi
done
- name: Convert Admonitions in Documentation
run: uv run python docs/scripts/convert_docs.py
- name: Build Documentation (PR Check)
if: github.event_name == 'pull_request'
run: uv run mkdocs build
- name: Build Preview Site (PR Check)
if: github.event_name == 'pull_request'
run: ASTRO_BASE=/preview/ npm --prefix docs/site run build
# Pre-submit only: verify that links in every Markdown file resolve,
# catching broken internal paths and dead external URLs. Placeholder URLs
# and tuning live in lychee.toml at the repository root.
- name: Restore lychee link-check cache
if: github.event_name == 'pull_request'
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: .lycheecache
key: lychee-${{ github.sha }}
restore-keys: lychee-
- name: Verify Markdown links (PR Check)
if: github.event_name == 'pull_request'
uses: lycheeverse/lychee-action@8646ba30535128ac92d33dfc9133794bfdd9b411 # v2.8.0
with:
args: >-
--config lychee.toml
--cache
--max-cache-age 1d
--no-progress
"**/*.md"
fail: true
env:
# Authenticated GitHub API requests avoid rate limits on github.com links.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy development version from main branch
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
uv run mkdocs build
ASTRO_BASE=/preview/ npm --prefix docs/site run build
rm -rf site/preview && cp -R docs/site/dist site/preview
# llms.txt is rendered by the Astro build; serve it from the site root.
cp docs/site/dist/llms.txt site/llms.txt
rm -f site/preview/CNAME site/preview/.nojekyll
uv run ghp-import --no-jekyll --push \
--message "Deployed $(git rev-parse --short HEAD) with MkDocs version: $(uv run python -c 'import mkdocs; print(mkdocs.__version__)')" \
site