-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (126 loc) · 5.05 KB
/
Copy pathdocs.yml
File metadata and controls
144 lines (126 loc) · 5.05 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
name: Release Docs
on:
workflow_call:
secrets:
PAT:
required: true
description: "Personal Access Token with access to the docs repository"
jobs:
build-docs:
permissions:
contents: read
id-token: write
name: Build Docs
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.11"
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: uv sync --extra docs
- name: Build docs
run: |
mkdir -p docs/build
uv run pydoc-markdown .pydoc-markdown.yml
- name: Checkout docs repo
uses: actions/checkout@v4
with:
repository: aurelio-labs/docs
path: temp-docs
ref: main
token: ${{ secrets.PAT }}
- name: Process regular documentation
run: |
ROOT_DIR=$(pwd)
# Clean existing documentation in target repo
rm -rf temp-docs/semantic-router
mkdir -p temp-docs/semantic-router/
# Define directories to process (excluding client-reference which is auto-generated separately)
DOC_DIRS=("get-started" "user-guide")
# Process each documentation directory
for doc_dir in "${DOC_DIRS[@]}"; do
echo "Processing directory: $doc_dir"
# Find all markdown files in the directory and its subdirectories
find "docs/$doc_dir" -type f -name "*.md" | while read file; do
# Get the relative path from the docs directory
rel_path=$(realpath --relative-to="docs/$doc_dir" "$(dirname "$file")")
file_name=$(basename "$file")
# Create target directory if it doesn't exist
if [ "$rel_path" = "." ]; then
# File is directly in the doc_dir
target_dir="$ROOT_DIR/temp-docs/semantic-router/$doc_dir"
else
# File is in a subdirectory
target_dir="$ROOT_DIR/temp-docs/semantic-router/$doc_dir/$rel_path"
fi
mkdir -p "$target_dir"
# Copy and rename from .md to .mdx
cp "$file" "$target_dir/${file_name%.md}.mdx"
echo "Copied $file to $target_dir/${file_name%.md}.mdx"
done
done
- name: Process reference documentation
run: |
ROOT_DIR=$(pwd)
rm -rf temp-docs/semantic-router/client-reference
mkdir -p temp-docs/semantic-router/client-reference/
# Check if build directory exists
if [ -d "docs/build/semantic_router" ]; then
# Find and copy all md files from reference docs
cd docs/build/semantic_router
find . -type f -name "*.md" | while read file; do
dir=$(dirname "$file")
echo "Processing file: $file in directory: $dir"
mkdir -p "$ROOT_DIR/temp-docs/semantic-router/client-reference/$dir"
cp "$file" "$ROOT_DIR/temp-docs/semantic-router/client-reference/${file%.md}.mdx"
done
else
echo "Warning: Reference docs build directory does not exist. Skipping reference documentation processing."
fi
- name: Update frontmatter keys
run: |
find temp-docs/semantic-router/client-reference -type f -name "*.mdx" -exec sed -i 's/sidebar_label:/sidebarTitle:/g' {} +
- name: Install jq
run: sudo apt-get install -y jq
- name: Update mintlify docs.json navigation
run: |
# Get files and create grouped structure using jq
files=$(cd temp-docs/semantic-router/client-reference && find . -type f -name "*.mdx" | sed 's|^./||' | sed 's|.mdx$||' | sort | jq -R -s '
split("\n")[:-1]
| map("semantic-router/client-reference/" + .)
| reduce .[] as $path (
{"root": [], "groups": {}};
if ($path | split("/") | length) == 4 then
.groups[$path | split("/")[2]] += [$path]
else
.root += [$path]
end
)
| [.root[], (.groups | to_entries | map({
"group": .key,
"pages": .value
}))[]
]
')
# Update the docs.json file
jq --arg pages "$files" '
(.navigation.tabs[] | select(.tab == "Semantic Router") |
.groups[] | select(.group == "Client Reference") |
.pages) |= ($pages | fromjson)
' temp-docs/docs.json > temp-docs/docs.json.tmp && mv temp-docs/docs.json.tmp temp-docs/docs.json
- name: Git commit and push
working-directory: temp-docs
run: |
git config --local user.email "admin@aurelio.ai"
git config --local user.name "aurelio-bot"
git remote set-url origin https://aurelio-bot:${{ secrets.PAT }}@github.com/aurelio-labs/docs.git
git add .
git diff --quiet && git diff --staged --quiet || (git commit -m "chore: update semantic router docs" && git push)