Skip to content

Commit 2eb2962

Browse files
authored
ci(sync): clean untracked files before syncing to release branch (#44)
1 parent eabd5d0 commit 2eb2962

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

.github/workflows/sync.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,23 @@ jobs:
4646
4747
- name: Push to release branch
4848
run: |
49-
git fetch origin release || git checkout --orphan release
50-
git checkout release || git checkout --orphan release
51-
52-
# Only remove the files/folders that are generated in dist/.
53-
# This safely preserves any release-specific files (like .github, AGENTS.md, etc.)
54-
# while perfectly cleaning up old/deleted skills inside the generated directories.
55-
ls -A dist | while read -r item; do
49+
STAGE_DIR=$(mktemp -d)
50+
cp -R dist/. "$STAGE_DIR"
51+
52+
git fetch origin release || true
53+
if git show-ref --verify --quiet refs/remotes/origin/release; then
54+
git checkout release
55+
else
56+
git checkout --orphan release
57+
fi
58+
git clean -fdx -e .git
59+
git checkout -- . 2>/dev/null || true
60+
61+
ls -A "$STAGE_DIR" | while read -r item; do
5662
rm -rf "$item"
5763
done
58-
59-
cp -R dist/. . && rm -rf dist
64+
65+
cp -R "$STAGE_DIR"/. . && rm -rf "$STAGE_DIR"
6066
6167
git config --local user.name "github-actions[bot]"
6268
git config --local user.email "github-actions[bot]@users.noreply.github.com"

0 commit comments

Comments
 (0)