Skip to content

Commit 41d1079

Browse files
authored
build(ci): some optimize
1 parent f349640 commit 41d1079

1 file changed

Lines changed: 35 additions & 11 deletions

File tree

.github/workflows/static.yml

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: 环境 - 构建库
2222
uses: actions/checkout@v4
2323
with:
24-
fetch-depth: 0
24+
fetch-depth: 1
2525
repository: LincZero/LincZero.github.io
2626
ref: 'main' # 分支,旧raw
2727

@@ -58,7 +58,40 @@ jobs:
5858
echo "}" >> git_config.json
5959
echo "::set-output name=REPO_NAME::$REPO_NAME"
6060
61-
# [!code] 根据实际情况修改
61+
- name: 文档 - 文档库克隆
62+
working-directory: ./src/
63+
run: |
64+
rm README.md
65+
66+
# 文档的克隆、构建、部署。注意 `clone --depth 1` 只拉最近一次提交,减少时间
67+
# git clone --depth 1 https://github.com/${GITHUB_REPOSITORY}.git # 如果有多个clone项则替换成这个,避免冲突
68+
git clone --depth 1 https://github.com/${GITHUB_REPOSITORY}.git temp_repo
69+
70+
# 该仓库为代理仓库,使用链接仓库而非此仓库
71+
if [ -f temp_repo/agency ]; then
72+
GIT_LINK=$(head -n 1 temp_repo/agency)
73+
rm -rf temp_repo
74+
git clone --depth 1 $GIT_LINK temp_repo
75+
echo "with agency"
76+
else
77+
echo "without agency"
78+
fi
79+
80+
- name: 文档 - 文档库docs文件夹的处理
81+
working-directory: ./src/
82+
run: |
83+
if [ -d temp_repo/docs ]; then
84+
find temp_repo/* -maxdepth 0 -name docs -prune -o -exec rm -rf {} \;
85+
mv temp_repo/docs/* .
86+
rm -rf temp_repo
87+
echo "with docs"
88+
else
89+
rsync -a temp_repo/ .
90+
rm -rf temp_repo
91+
echo "without docs"
92+
fi
93+
94+
# [!code] 根据实际情况修改 (需要在仓库配置写入以及和文档仓库clone这两个步骤的后面)
6295
- name: 配置 - 设置
6396
working-directory: ./
6497
run: |
@@ -68,15 +101,6 @@ jobs:
68101
rm -f ./src/.vuepress/theme_cover.js
69102
pnpm run gen-config
70103
71-
# 文档的克隆、构建、部署。注意 `clone --depth 1` 只拉最近一次提交,减少时间
72-
- name: 文档 - 文档库克隆
73-
working-directory: ./src/
74-
run: |
75-
git clone --depth 1 https://github.com/${GITHUB_REPOSITORY}.git temp_repo
76-
rsync -a temp_repo/ .
77-
rm -rf temp_repo
78-
# git clone --depth 1 https://github.com/${GITHUB_REPOSITORY}.git # 如果有多个clone项则替换成这个,避免冲突
79-
80104
- name: 文档 - 构建
81105
env:
82106
NODE_OPTIONS: --max_old_space_size=20480

0 commit comments

Comments
 (0)