Merge pull request #23 from modelstudioai/feat/auto-generate-skills

Feat/auto generate skills
This commit is contained in:
Gong Shiqi
2026-06-05 14:07:47 +08:00
committed by GitHub
@@ -0,0 +1,127 @@
# When the CLI command catalog changes, regenerate skill reference markdown,
# push to modelstudioai/skills, and open a PR against main.
#
# Required repository secret (Settings → Secrets and variables → Actions):
# SKILLS_SYNC_TOKEN — PAT with repo scope on modelstudioai/skills:
# Contents: Read and write
# Pull requests: Read and write
# Prefer a bot / machine user PAT if your org restricts personal PATs.
name: Sync bailian-cli skill reference
on:
push:
branches: [main]
paths:
- "packages/cli/src/commands/catalog.ts"
schedule:
- cron: "0 19 * * *"
workflow_dispatch:
concurrency:
group: sync-bailian-cli-skill-reference
cancel-in-progress: true
jobs:
sync:
runs-on: ubuntu-latest
if: github.repository == 'modelstudioai/cli'
permissions:
contents: read
steps:
- name: Checkout cli
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.33.2
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build bailian-cli-core (required by generate-reference)
run: pnpm --filter bailian-cli-core run build
- name: Generate reference markdown
run: pnpm --filter bailian-cli run generate:reference
- name: Checkout skills repo
uses: actions/checkout@v4
with:
repository: modelstudioai/skills
path: skills-repo
token: ${{ secrets.SKILLS_SYNC_TOKEN }}
fetch-depth: 0
- name: Sync reference into skills and open PR
env:
GH_TOKEN: ${{ secrets.SKILLS_SYNC_TOKEN }}
CLI_SHA: ${{ github.sha }}
CLI_RUN: ${{ github.run_id }}
run: |
set -euo pipefail
cd "${GITHUB_WORKSPACE}/skills-repo"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git fetch origin main
git checkout main
git pull origin main
SHORT_SHA="${CLI_SHA:0:7}"
BRANCH="sync/bailian-cli-reference-${SHORT_SHA}"
git checkout -B "$BRANCH"
SRC="${GITHUB_WORKSPACE}/tools/generated/reference"
DEST="${GITHUB_WORKSPACE}/skills-repo/skills/bailian-cli/reference"
mkdir -p "$DEST"
rsync -a --delete "$SRC/" "$DEST/"
# Stage before checking: untracked new files are invisible to `git diff` until added.
git add -A -- skills/bailian-cli/reference
if git diff --cached --quiet; then
echo "No changes to skill reference; exiting."
exit 0
fi
RUN_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${CLI_RUN}"
git commit \
-m "chore(bailian-cli): sync reference from cli" \
-m "Synced from modelstudioai/cli@${CLI_SHA}" \
-m "Workflow run: ${RUN_URL}"
# Branch is automation-owned; lease-safe force covers re-runs / updated main base.
git push -u origin "$BRANCH" --force-with-lease
EXISTING=$(gh pr list --repo modelstudioai/skills --head "$BRANCH" --state open --json number --jq 'length')
if [ "${EXISTING}" -eq 0 ]; then
BODY_FILE="$(mktemp)"
{
echo "## Summary"
echo ""
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}\`)."
echo ""
echo "## Test plan"
echo ""
echo "- [ ] Spot-check \`reference/index.md\` links and a sample group file under \`skills/bailian-cli/reference/\`."
echo "- [ ] Merge if docs only."
} >"$BODY_FILE"
gh pr create \
--repo modelstudioai/skills \
--base main \
--head "$BRANCH" \
--title "chore(bailian-cli): sync CLI command reference" \
--body-file "$BODY_FILE"
rm -f "$BODY_FILE"
else
echo "Open PR already exists for head ${BRANCH}."
fi