Skip to content

Commit bf6eafb

Browse files
authored
Refactor build workflow to optimize .next directory handling
Updated the build workflow to use rsync for copying the .next directory while excluding the cache. Removed unnecessary steps for cleaning and copying files.
1 parent e437a78 commit bf6eafb

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

.github/workflows/build-to-branch.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,27 +65,17 @@ jobs:
6565
git config user.name "github-actions"
6666
git config user.email "github-actions@github.com"
6767
68-
# 保存 .gitignore
69-
cp .gitignore /tmp/gitignore.tmp
68+
# 拷贝 .next 但排除 cache
69+
rsync -av --exclude='cache' .next/ /tmp/next-build
7070
7171
# 切换或创建 build 分支
7272
git checkout -B build
7373
74-
# 清空分支(只保留 build 产物)
74+
# 清空分支
7575
git rm -rf .
7676
7777
# 把 build 产物拷进去(按需修改)
78-
cp -r .next/* .
79-
80-
# 清理缓存
81-
rm -rf .next/cache
82-
83-
# 如果你还有 public / package.json / next.config.js
84-
# cp -r public .
85-
# cp package.json next.config.js .
86-
87-
# copy .gitignore
88-
cp /tmp/gitignore.tmp .gitignore
78+
cp -r /tmp/next-build .next
8979
9080
git add .next
9181
git commit -m "chore: build from $GITHUB_SHA"

0 commit comments

Comments
 (0)