Skip to content

Commit 7442adb

Browse files
committed
update
1 parent 94adbc4 commit 7442adb

1 file changed

Lines changed: 19 additions & 56 deletions

File tree

.github/workflows/static.yml

Lines changed: 19 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
# take from https://github.com/LincDocs/Workflow
2-
31
name: 部署文档
42

53
on:
64
push:
75
branches: ["main"] # 确保这是你正在使用的分支名称
8-
schedule:
9-
# 定时任务。建议多个仓库错开,避免多个仓库同一时间一起坏掉。我个人用键盘阵列映射周1~5。特别是代理仓库比较需要这个
10-
- cron: '30 10 * * 1' # 每周一10:30触发工作流
116
workflow_dispatch:
127

138
permissions:
@@ -31,15 +26,15 @@ jobs:
3126
ref: 'main' # 分支,旧raw
3227

3328
- name: 环境 - 安装 pnpm
34-
uses: pnpm/action-setup@v4
29+
uses: pnpm/action-setup@v2
3530
with:
3631
run_install: true
37-
version: 9
32+
version: 8
3833

3934
- name: 环境 - 设置 Node.js
40-
uses: actions/setup-node@v4
35+
uses: actions/setup-node@v3
4136
with:
42-
node-version: 22
37+
node-version: 20
4338
cache: pnpm
4439

4540
# 获取仓库的相关配置
@@ -57,57 +52,13 @@ jobs:
5752
echo " \"GITHUB_REPOSITORY_OWNER\": \"${GITHUB_REPOSITORY_OWNER}\"," >> git_config.json # 仓库所属(格式: 可以是组织)
5853
echo " \"GITHUB_ACTOR\": \"${GITHUB_ACTOR}\"," >> git_config.json # 仓库作者(格式: 不会是组织)
5954
echo " \"GITHUB_REPOSITORY\": \"${GITHUB_REPOSITORY}\"," >> git_config.json # 仓库标识(格式: 个人或组织/仓库名)
60-
echo " \"CALC_URL\": \"${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/\"," >> git_config.json # 仓库url
55+
echo " \"CALC_URL\": \"${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/\"," >> git_config.json # 仓库url
6156
REPO_NAME=$(echo "${GITHUB_REPOSITORY}" | cut -d"/" -f2)
6257
echo " \"CALC_REPO_NAME\": \"${REPO_NAME}\"" >> git_config.json # 仓库无前缀名
6358
echo "}" >> git_config.json
6459
echo "::set-output name=REPO_NAME::$REPO_NAME"
6560
66-
- name: 文档 - 文档克隆1 # 文档的克隆、构建、部署。注意 `clone --depth 1` 只拉最近一次提交,减少时间
67-
working-directory: ./src/
68-
run: |
69-
rm README.md
70-
71-
# git clone --depth 1 https://github.com/${GITHUB_REPOSITORY}.git # 如果有多个clone项则替换成这个,避免冲突
72-
# --depth 1 选项会损失git历史,但能加速编译。可自行启用/关闭
73-
# 注意若使用该选项,必须要删除 .git 文件夹,避免时间和贡献者错乱
74-
git clone --depth 1 https://github.com/${GITHUB_REPOSITORY}.git temp_repo
75-
rm -rf temp_repo/.git
76-
77-
- name: 文档 - 文档克隆2, 允许使用代理仓库/指定文件夹
78-
working-directory: ./src/
79-
run: |
80-
# step1. 克隆被代理仓库
81-
# 该仓库为代理仓库时,使用链接仓库而非此仓库
82-
# TODO 支持agency多个仓库。如果想更通用,干脆支持直接运行agency里的命令组
83-
if [ -f temp_repo/agency ]; then
84-
echo "with agency"
85-
GIT_LINK=$(sed -n '1p' temp_repo/agency | tr -d '\r')
86-
DIR=$(sed -n '2p' temp_repo/agency | tr -d '\r')
87-
rm -rf temp_repo
88-
git clone --depth 1 $GIT_LINK temp_repo
89-
rm -rf temp_repo/.git
90-
else
91-
echo "without agency"
92-
DIR="docs/"
93-
fi
94-
95-
# 使用指定文件夹
96-
if [ -d "temp_repo/${DIR}" ]; then
97-
echo "with docs folder: temp_repo/${DIR}"
98-
# find temp_repo/* -maxdepth 0 -name docs -prune -o -exec rm -rf {} \;
99-
# ls -l temp_repo/website/docs/ # debug
100-
mv "temp_repo/${DIR}"/* .
101-
rm -rf temp_repo
102-
else
103-
echo "without docs folder: temp_repo/${DIR}"
104-
rsync -a temp_repo/ .
105-
rm -rf temp_repo
106-
fi
107-
echo "---"
108-
ls
109-
110-
# [!code] 根据实际情况修改 (需要在仓库配置写入以及和文档仓库clone这两个步骤的后面)
61+
# [!code] 根据实际情况修改
11162
- name: 配置 - 设置
11263
working-directory: ./
11364
run: |
@@ -117,6 +68,18 @@ jobs:
11768
rm -f ./src/.vuepress/theme_cover.js
11869
pnpm run gen-config
11970
71+
# 文档的克隆、构建、部署。注意 `clone --depth 1` 只拉最近一次提交,减少时间
72+
- name: 文档 - 文档库克隆
73+
working-directory: ./src/
74+
run: |
75+
# --depth 1 选项会损失git历史,但能加速编译。可自行启用/关闭
76+
# 注意若使用该选项,必须要删除 .git 文件夹,避免时间和贡献者错乱
77+
git clone --depth 1 https://github.com/${GITHUB_REPOSITORY}.git temp_repo
78+
rm -rf temp_repo/.git
79+
rsync -a temp_repo/ .
80+
rm -rf temp_repo
81+
# git clone --depth 1 https://github.com/${GITHUB_REPOSITORY}.git # 如果有多个clone项则替换成这个,避免冲突
82+
12083
- name: 文档 - 构建
12184
env:
12285
NODE_OPTIONS: --max_old_space_size=20480
@@ -126,7 +89,7 @@ jobs:
12689
> src/.vuepress/dist/.nojekyll
12790
12891
- name: 文档 - 部署
129-
uses: JamesIves/github-pages-deploy-action@v4.7.3
92+
uses: JamesIves/github-pages-deploy-action@v4
13093
with:
13194
# 这是文档部署到的分支名称
13295
branch: gh-pages

0 commit comments

Comments
 (0)