Skip to content

Commit 8ee570a

Browse files
committed
feat: Optimize the monitoring of command changes to avoid invalid pull requests (PRs)
1 parent 6494e68 commit 8ee570a

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

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

Lines changed: 17 additions & 6 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,9 @@ 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"
1719
schedule:
1820
- cron: "0 19 * * *"
1921
workflow_dispatch:
@@ -88,8 +90,9 @@ jobs:
8890
# Stage before checking: untracked new files are invisible to `git diff` until added.
8991
git add -A -- skills/bailian-cli/reference
9092
91-
if git diff --cached --quiet; then
92-
echo "No changes to skill reference; exiting."
93+
# Compare staged tree to skills repo main (explicit); no diff → no commit / no PR.
94+
if git diff --cached --quiet origin/main; then
95+
echo "No diff vs origin/main under skills/bailian-cli/reference; exiting."
9396
exit 0
9497
fi
9598
@@ -102,13 +105,21 @@ jobs:
102105
# Branch is automation-owned; lease-safe force covers re-runs / updated main base.
103106
git push -u origin "$BRANCH" --force-with-lease
104107
108+
git fetch origin main
109+
if git diff --quiet origin/main HEAD; then
110+
echo "Branch tree matches origin/main; skipping PR creation."
111+
git push origin --delete "$BRANCH"
112+
echo "Deleted remote branch ${BRANCH} (no PR opened)."
113+
exit 0
114+
fi
115+
105116
EXISTING=$(gh pr list --repo modelstudioai/skills --head "$BRANCH" --state open --json number --jq 'length')
106117
if [ "${EXISTING}" -eq 0 ]; then
107118
BODY_FILE="$(mktemp)"
108119
{
109120
echo "## Summary"
110121
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}\`)."
122+
echo "- Regenerated \`skills/bailian-cli/reference/*.md\` from CLI command definitions at [\`modelstudioai/cli\`](https://github.com/modelstudioai/cli) commit \`${SHORT_SHA}\`."
112123
echo ""
113124
echo "## Test plan"
114125
echo ""

0 commit comments

Comments
 (0)