fix(ci): robust catalog sync (untracked-file guard, mkdir, rebase) + stale-catalog gate

This commit is contained in:
DrSmoothl committed 2026-06-26 22:03:42 +08:00
1 parent 75f14540c8
commit 0163af979a
2 files changed
+23 -5

No files matched your search

+10
View File
@@ -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
+13 -5
View File
@@ -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