Newer
Older
push:
branches:
- main
name: Build Docs
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
python-version: ${{ matrix.python-version }}
uv run pydoc-markdown .pydoc-markdown.yml
- name: Checkout docs repo
uses: actions/checkout@v4
repository: aurelio-labs/docs
path: temp-docs
- name: Copy and rename docs
run: |
ROOT_DIR=$(pwd)
rm -rf temp-docs/semantic-router/client-reference
mkdir -p temp-docs/semantic-router/client-reference/
# Find and copy all md files
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
- 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
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 diff --quiet && git diff --staged --quiet || (git commit -m "chore: update semantic router docs" && git push)