fix(ci): robust catalog sync (untracked-file guard, mkdir, rebase) + stale-catalog gate
This commit is contained in:
2 files changed
+23
-5
No files matched your search
@@ -41,3 +41,13 @@ jobs:
|
|||||||
|
|
||||||
- name: Run all package tests
|
- name: Run all package tests
|
||||||
run: pnpm -r --no-bail --if-present test
|
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
|
||||||
@@ -90,17 +90,25 @@ jobs:
|
|||||||
OWNER: ${{ github.repository_owner }}
|
OWNER: ${{ github.repository_owner }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
src="$(pwd)/packages/mcp/src/generated/catalog.json"
|
||||||
tmp="$(mktemp -d)"
|
tmp="$(mktemp -d)"
|
||||||
git clone --depth 1 \
|
git clone --depth 1 \
|
||||||
"https://x-access-token:${GH_TOKEN}@github.com/${OWNER}/SnowLumaDocs.git" "$tmp"
|
"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"
|
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."
|
echo "::notice::catalog.json unchanged; nothing to sync."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
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}"
|
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
|
git push origin HEAD:main
|
||||||
Reference in new issue
Block a user