Files
workflows-py/scripts/sync-docs-to-developer-hub.sh
Adrian Lyjak b4bdcda384 fix(docs-sync): resolve developer-hub path to absolute before cd (#540)
The sync-docs-to-developer-hub.sh script accepts the developer-hub repo
path as its first argument. The CI workflow passes it as a relative path
(`developer-hub`) pointing to the checkout at the repo root. The markdown
rsync step ran before any `cd`, so the relative path resolved correctly,
but the mkdocs build step `cd`s into docs/api_docs first and then uses
the still-relative `$DOCS_REPO/api-reference/python/workflows` as its
output directory. mkdocs consequently wrote the built API reference to
`docs/api_docs/developer-hub/...` inside the source repo instead of into
the actual developer-hub checkout, so the subsequent
`git add api-reference/python/workflows/` found nothing to commit and
the API reference was never synced downstream.

Resolve $DOCS_REPO to an absolute path once up front so later `cd`s do
not change its meaning.

Co-authored-by: Claude <noreply@anthropic.com>
2026-04-15 01:09:52 +00:00

41 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
DOCS_REPO_ARG="${1:?Usage: $0 /path/to/developer-hub-repo}"
# Resolve to an absolute path up front: later commands `cd` before using this,
# so a relative path would resolve against the wrong directory.
mkdir -p "$DOCS_REPO_ARG"
DOCS_REPO="$(cd "$DOCS_REPO_ARG" && pwd)"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
# --- Markdown docs ---
SOURCE_DIR="$REPO_ROOT/docs/src/content/docs/llamaagents"
DEST_DIR="$DOCS_REPO/src/content/docs/python/llamaagents"
echo "=== Syncing markdown docs ==="
mkdir -p "$DEST_DIR"
rsync -av --delete \
--include='*/' \
--include='*.md' \
--include='*.mdx' \
--include='*.yml' \
--include='*.png' \
--include='*.jpg' \
--include='*.jpeg' \
--include='*.svg' \
--exclude='*' \
"$SOURCE_DIR/" "$DEST_DIR/"
# --- API reference (mkdocs HTML) ---
API_DOCS_DIR="$REPO_ROOT/docs/api_docs"
API_DEST_DIR="$DOCS_REPO/api-reference/python/workflows"
echo "=== Building workflows API reference ==="
cd "$API_DOCS_DIR"
uv sync --locked
uv run mkdocs build -d "$API_DEST_DIR"
echo "Docs sync complete."