diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2dc526e5..5bf09869 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,3 +41,13 @@ jobs: - name: Run all package tests run: pnpm -r --no-bail --if-present test + + # The MCP test suite regenerates the action catalog (catalog.ts + the + # catalog.json the docs site consumes). Fail if the committed snapshot + # drifted from the live specs — keeps the API docs from going stale. + - name: Verify generated action catalog is up to date + run: | + if ! git diff --exit-code -- packages/mcp/src/generated; then + echo '::error::Generated action catalog is stale. Run `pnpm --filter @snowluma/mcp gen` and commit packages/mcp/src/generated/.' >&2 + exit 1 + fi diff --git a/.github/workflows/sync-docs-catalog.yml b/.github/workflows/sync-docs-catalog.yml index 31a26e89..70c842db 100644 --- a/.github/workflows/sync-docs-catalog.yml +++ b/.github/workflows/sync-docs-catalog.yml @@ -90,17 +90,25 @@ jobs: OWNER: ${{ github.repository_owner }} run: | set -euo pipefail + src="$(pwd)/packages/mcp/src/generated/catalog.json" tmp="$(mktemp -d)" git clone --depth 1 \ "https://x-access-token:${GH_TOKEN}@github.com/${OWNER}/SnowLumaDocs.git" "$tmp" - cp packages/mcp/src/generated/catalog.json "$tmp/docs/public/api/catalog.json" + mkdir -p "$tmp/docs/public/api" + cp "$src" "$tmp/docs/public/api/catalog.json" cd "$tmp" - if git diff --quiet -- docs/public/api/catalog.json; then + git config user.name "${BOT_LOGIN}" + git config user.email "${BOT_EMAIL}" + # Stage first: `git diff --quiet` ignores UNTRACKED files, so on the + # initial sync (catalog.json not yet in the docs repo) the index diff + # is the only reliable change check. + git add docs/public/api/catalog.json + if git diff --cached --quiet; then echo "::notice::catalog.json unchanged; nothing to sync." exit 0 fi - git config user.name "${BOT_LOGIN}" - git config user.email "${BOT_EMAIL}" - git add docs/public/api/catalog.json git commit -m "chore(api): sync action catalog from SnowLuma@${GITHUB_SHA::7}" + # Single writer, but guard against a concurrent docs commit racing the + # shallow clone: rebase onto the latest main before pushing. + git pull --rebase --depth 1 origin main git push origin HEAD:main