Skip to content

Commit 55e591e

Browse files
Merge pull request #28 from modelstudioai/feat/auto-generate-skills
feat: Optimize the monitoring of command changes to avoid invalid pul…
2 parents d08fa2b + f26e288 commit 55e591e

1 file changed

Lines changed: 26 additions & 10 deletions

File tree

.github/workflows/sync-bailian-cli-skill-reference.yml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# When the CLI command catalog changes, regenerate skill reference markdown,
2-
# push to modelstudioai/skills, and open a PR against main.
1+
# When CLI command definitions or the reference generator change, regenerate skill
2+
# reference markdown, push to modelstudioai/skills, and open a PR against main.
33
#
44
# Required repository secret (Settings → Secrets and variables → Actions):
55
# SKILLS_SYNC_TOKEN — PAT with repo scope on modelstudioai/skills:
@@ -13,7 +13,15 @@ on:
1313
push:
1414
branches: [main]
1515
paths:
16-
- "packages/cli/src/commands/catalog.ts"
16+
- "packages/cli/src/commands/**"
17+
- "tools/generate-reference.ts"
18+
- "packages/core/src/types/command.ts"
19+
paths-ignore:
20+
# Tests and fixtures under commands/ do not affect generated reference.
21+
- "packages/cli/src/commands/**/*.test.ts"
22+
- "packages/cli/src/commands/**/*.spec.ts"
23+
- "packages/cli/src/commands/**/__fixtures__/**"
24+
- "packages/cli/src/commands/**/__tests__/**"
1725
schedule:
1826
- cron: "0 19 * * *"
1927
workflow_dispatch:
@@ -78,18 +86,20 @@ jobs:
7886
7987
SHORT_SHA="${CLI_SHA:0:7}"
8088
BRANCH="sync/bailian-cli-reference-${SHORT_SHA}"
89+
REFERENCE_PATH="skills/bailian-cli/reference"
90+
8191
git checkout -B "$BRANCH"
8292
8393
SRC="${GITHUB_WORKSPACE}/tools/generated/reference"
84-
DEST="${GITHUB_WORKSPACE}/skills-repo/skills/bailian-cli/reference"
94+
DEST="${GITHUB_WORKSPACE}/skills-repo/${REFERENCE_PATH}"
8595
mkdir -p "$DEST"
8696
rsync -a --delete "$SRC/" "$DEST/"
8797
88-
# Stage before checking: untracked new files are invisible to `git diff` until added.
89-
git add -A -- skills/bailian-cli/reference
98+
# Untracked new files are invisible to `git diff` until added.
99+
git add -A -- "$REFERENCE_PATH"
90100
91-
if git diff --cached --quiet; then
92-
echo "No changes to skill reference; exiting."
101+
if git diff --cached --quiet origin/main -- "$REFERENCE_PATH"; then
102+
echo "No diff vs origin/main under ${REFERENCE_PATH}; exiting."
93103
exit 0
94104
fi
95105
@@ -99,7 +109,13 @@ jobs:
99109
-m "Synced from modelstudioai/cli@${CLI_SHA}" \
100110
-m "Workflow run: ${RUN_URL}"
101111
102-
# Branch is automation-owned; lease-safe force covers re-runs / updated main base.
112+
# Re-fetch before push: main may have been updated with the same reference content.
113+
git fetch origin main
114+
if git diff --quiet origin/main HEAD -- "$REFERENCE_PATH"; then
115+
echo "Committed tree matches origin/main; skipping push and PR."
116+
exit 0
117+
fi
118+
103119
git push -u origin "$BRANCH" --force-with-lease
104120
105121
EXISTING=$(gh pr list --repo modelstudioai/skills --head "$BRANCH" --state open --json number --jq 'length')
@@ -108,7 +124,7 @@ jobs:
108124
{
109125
echo "## Summary"
110126
echo ""
111-
echo "- Regenerated \`skills/bailian-cli/reference/*.md\` from [\`packages/cli/src/commands/catalog.ts\`](https://github.com/modelstudioai/cli/blob/${CLI_SHA}/packages/cli/src/commands/catalog.ts) in [\`modelstudioai/cli\`](https://github.com/modelstudioai/cli) (commit \`${SHORT_SHA}\`)."
127+
echo "- Regenerated \`skills/bailian-cli/reference/*.md\` from CLI command definitions at [\`modelstudioai/cli\`](https://github.com/modelstudioai/cli) commit \`${SHORT_SHA}\`."
112128
echo ""
113129
echo "## Test plan"
114130
echo ""

0 commit comments

Comments
 (0)