Skip to content

Commit f26e288

Browse files
committed
feat: Diff check optimization
1 parent 8ee570a commit f26e288

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ on:
1616
- "packages/cli/src/commands/**"
1717
- "tools/generate-reference.ts"
1818
- "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__/**"
1925
schedule:
2026
- cron: "0 19 * * *"
2127
workflow_dispatch:
@@ -80,19 +86,20 @@ jobs:
8086
8187
SHORT_SHA="${CLI_SHA:0:7}"
8288
BRANCH="sync/bailian-cli-reference-${SHORT_SHA}"
89+
REFERENCE_PATH="skills/bailian-cli/reference"
90+
8391
git checkout -B "$BRANCH"
8492
8593
SRC="${GITHUB_WORKSPACE}/tools/generated/reference"
86-
DEST="${GITHUB_WORKSPACE}/skills-repo/skills/bailian-cli/reference"
94+
DEST="${GITHUB_WORKSPACE}/skills-repo/${REFERENCE_PATH}"
8795
mkdir -p "$DEST"
8896
rsync -a --delete "$SRC/" "$DEST/"
8997
90-
# Stage before checking: untracked new files are invisible to `git diff` until added.
91-
git add -A -- skills/bailian-cli/reference
98+
# Untracked new files are invisible to `git diff` until added.
99+
git add -A -- "$REFERENCE_PATH"
92100
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."
101+
if git diff --cached --quiet origin/main -- "$REFERENCE_PATH"; then
102+
echo "No diff vs origin/main under ${REFERENCE_PATH}; exiting."
96103
exit 0
97104
fi
98105
@@ -102,17 +109,15 @@ jobs:
102109
-m "Synced from modelstudioai/cli@${CLI_SHA}" \
103110
-m "Workflow run: ${RUN_URL}"
104111
105-
# Branch is automation-owned; lease-safe force covers re-runs / updated main base.
106-
git push -u origin "$BRANCH" --force-with-lease
107-
112+
# Re-fetch before push: main may have been updated with the same reference content.
108113
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)."
114+
if git diff --quiet origin/main HEAD -- "$REFERENCE_PATH"; then
115+
echo "Committed tree matches origin/main; skipping push and PR."
113116
exit 0
114117
fi
115118
119+
git push -u origin "$BRANCH" --force-with-lease
120+
116121
EXISTING=$(gh pr list --repo modelstudioai/skills --head "$BRANCH" --state open --json number --jq 'length')
117122
if [ "${EXISTING}" -eq 0 ]; then
118123
BODY_FILE="$(mktemp)"

0 commit comments

Comments
 (0)