Skip to content

Commit 43e9d0f

Browse files
authored
refactor: migrate SSG to VitePress, migrate website to zotero-chinese/website repo (#172)
* refactor: migration to vitepress * fix: dead link * fix: homepage * fix: update homepage * fix: sidebar and container syntax * 分离配置文件 * refactor: mv docs to root * tweak * ci: fix path * Add dev mode tip * ci: dispatch website * fix: use satisfies types * fix: migrate about.md to website * fix: types * chore: update lint workflow * fix: vbnet -> vb * ci: fix ci error * ci: do not specify pnpm version * ci: use chinese name * ci: rewrite workflows * ci: fix deploy no pnpm lock * ci: fix netlify dist dir * ci: 尝试修改评论顺序 * fix: 不再需要设置base * ci: 测试失败 * Revert "ci: 尝试修改评论顺序" This reverts commit e362e88. * ci: 修改标题描述 * ci: 撤回先前的测试 * ci: fix netlify url * ci: 使用action netlify * ci: 修复url * clean code * ci: 区分website仓库的alias * 允许手动触发 [skip ci]
1 parent 66d4259 commit 43e9d0f

526 files changed

Lines changed: 2105 additions & 4214 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
File renamed without changes.

.github/workflows/deploy-gh-pages.yml renamed to .github/workflows/backup/deploy-gh-pages.yml.bak

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy GitHub Pages
1+
name: 部署预览版本
22

33
on:
44
workflow_call:
@@ -23,16 +23,16 @@ jobs:
2323
# path: dist.tar
2424

2525
- name: 解压构建文件
26-
run: tar -xvf dist.tar src/.vuepress/dist
26+
run: tar -xvf dist.tar .vitepress/dist
2727

2828
- name: 列出构建内容目录结构
2929
run: ls -R -a
3030

3131
- name: 部署到 GitHub
3232
uses: JamesIves/github-pages-deploy-action@v4
3333
with:
34-
repository-name: zotero-chinese/zotero-chinese.github.io
34+
# repository-name: zotero-chinese/zotero-chinese.github.io
3535
branch: gh-pages
36-
folder: src/.vuepress/dist
36+
folder: .vitepress/dist
3737
single-commit: true
3838
token: ${{ secrets.ACCESS_TOKEN }}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
lint:
16+
name: 检查文档格式
17+
uses: ./.github/workflows/lint.yml
18+
with:
19+
fix: ${{ contains(github.event_name, 'pull_request') }}
20+
21+
build:
22+
name: 构建文档
23+
uses: ./.github/workflows/build.yml
24+
25+
deploy-gh-pages:
26+
name: 部署预览版本
27+
if: github.ref_name == 'main' && github.event_name == 'push' && github.repository == 'zotero-chinese/wiki'
28+
needs:
29+
- lint
30+
- build
31+
uses: ./.github/workflows/deploy-gh-pages.yml
32+
secrets:
33+
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
34+
35+
send-dispatch:
36+
name: 请求部署上线
37+
if: github.ref_name == 'main' && github.event_name == 'push' && github.repository == 'zotero-chinese/wiki'
38+
needs:
39+
- lint
40+
- build
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Repository Dispatch
44+
uses: peter-evans/repository-dispatch@v3
45+
with:
46+
token: ${{ secrets.ACCESS_TOKEN }}
47+
repository: zotero-chinese/website
48+
event-type: update-content

‎.github/workflows/build.yml‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build
1+
name: 构建预览版本
22

33
on:
44
workflow_call:
@@ -16,6 +16,8 @@ jobs:
1616

1717
- name: 设置 pnpm
1818
uses: pnpm/action-setup@v2
19+
with:
20+
version: 9
1921

2022
- name: 设置 Node.js
2123
uses: actions/setup-node@v4
@@ -31,10 +33,10 @@ jobs:
3133
NODE_OPTIONS: --max_old_space_size=8192
3234
run: |-
3335
pnpm run docs:build
34-
> src/.vuepress/dist/.nojekyll
36+
> .vitepress/dist/.nojekyll
3537
3638
- name: 压缩构建文件
37-
run: tar -cvf dist.tar src/.vuepress/dist
39+
run: tar -cvf dist.tar .vitepress/dist
3840

3941
- name: 上传构建结果
4042
uses: actions/upload-artifact@v4

‎.github/workflows/ci-preview.yml‎

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: 部署预览
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
lint:
13+
name: 检查文档格式
14+
uses: ./.github/workflows/lint.yml
15+
with:
16+
fix: true
17+
18+
build:
19+
name: 构建文档
20+
uses: ./.github/workflows/build.yml
21+
22+
deploy:
23+
name: 部署预览
24+
needs:
25+
- lint
26+
- build
27+
runs-on: ubuntu-latest
28+
permissions:
29+
pull-requests: write
30+
steps:
31+
- name: 下载构建内容
32+
uses: actions/download-artifact@v4
33+
with:
34+
name: build-result
35+
# path: dist.tar
36+
37+
- name: 解压构建文件
38+
run: |
39+
tar -xvf dist.tar .vitepress/dist
40+
# ls -R -a
41+
42+
- name: 推送到 Netlify
43+
id: netlify
44+
uses: nwtgck/actions-netlify@v3.0
45+
with:
46+
publish-dir: ".vitepress/dist"
47+
deploy-message: "Deploy from GitHub Actions"
48+
production-deploy: false
49+
alias: deploy-preview-wiki-${{ github.event.number }}
50+
enable-commit-comment: false
51+
enable-pull-request-comment: false
52+
enable-commit-status: false
53+
enable-github-deployment: false
54+
env:
55+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
56+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
57+
timeout-minutes: 1
58+
59+
- name: 查找评论 ID
60+
uses: peter-evans/find-comment@v2
61+
id: fc
62+
with:
63+
issue-number: ${{ github.event.number }}
64+
comment-author: "github-actions[bot]"
65+
body-includes: <!-- auto message -->
66+
67+
- name: 创建或更新评论
68+
uses: peter-evans/create-or-update-comment@v3
69+
with:
70+
comment-id: ${{ steps.fc.outputs.comment-id }}
71+
issue-number: ${{ github.event.number }}
72+
body: |
73+
<!-- auto message -->
74+
75+
## ✅ 成功部署预览!
76+
77+
| 类型 | 链接 |
78+
|:---------:|:--------------------------------------:|
79+
| 预览地址 | ${{ steps.netlify.outputs.deploy-url }} |
80+
edit-mode: replace
81+
82+
on-failure:
83+
name: 提示部署结果
84+
runs-on: ubuntu-latest
85+
permissions:
86+
pull-requests: write
87+
needs:
88+
- lint
89+
- build
90+
- deploy
91+
if: ${{ failure() }}
92+
steps:
93+
- name: 查找评论 ID
94+
uses: peter-evans/find-comment@v2
95+
id: fc
96+
with:
97+
issue-number: ${{ github.event.number }}
98+
comment-author: "github-actions[bot]"
99+
body-includes: <!-- auto message -->
100+
101+
- name: 创建或更新评论:失败
102+
uses: peter-evans/create-or-update-comment@v3
103+
with:
104+
comment-id: ${{ steps.fc.outputs.comment-id }}
105+
issue-number: ${{ github.event.number }}
106+
body: |
107+
<!-- auto message -->
108+
109+
## ❌ 部署预览失败
110+
111+
部署失败,请查看工作流的运行状态和日志。
112+
edit-mode: replace

‎.github/workflows/ci-prod.yml‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Deploy in Production Mode
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
lint:
14+
name: 检查文档格式
15+
uses: ./.github/workflows/lint.yml
16+
with:
17+
fix: false
18+
19+
build:
20+
name: 构建文档
21+
uses: ./.github/workflows/build.yml
22+
23+
send-dispatch:
24+
name: 请求部署上线
25+
if: github.repository == 'zotero-chinese/wiki'
26+
needs:
27+
- lint
28+
- build
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Repository Dispatch
32+
uses: peter-evans/repository-dispatch@v3
33+
with:
34+
token: ${{ secrets.ACCESS_TOKEN }}
35+
repository: zotero-chinese/website
36+
event-type: update-content

‎.github/workflows/lint.yml‎

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,53 @@
1-
name: Lint Markdown
1+
name: 检查文档格式
22

33
on:
44
workflow_call:
5+
inputs:
6+
fix:
7+
required: true
8+
type: boolean
59

610
jobs:
711
lint:
812
runs-on: ubuntu-latest
913
steps:
1014
- name: 签出仓库
1115
uses: actions/checkout@v4
12-
- name: 运行 MarkdownLint
13-
uses: DavidAnson/markdownlint-cli2-action@v16
1416
with:
15-
globs: |
16-
**/*.md
17-
!test/*.md
17+
fetch-depth: 0
18+
19+
- name: 设置 pnpm
20+
uses: pnpm/action-setup@v2
21+
with:
22+
version: 9
23+
24+
- name: 设置 Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 20
28+
cache: pnpm
29+
30+
- name: 安装依赖
31+
run: pnpm install
32+
33+
- name: 运行 Lint 检查
34+
if: inputs.fix == false
35+
env:
36+
NODE_OPTIONS: --max_old_space_size=8192
37+
run: |-
38+
pnpm run lint:check
39+
40+
- name: 运行 Lint 修复
41+
if: inputs.fix
42+
env:
43+
NODE_OPTIONS: --max_old_space_size=8192
44+
run: |-
45+
pnpm run lint:fix
46+
47+
- name: 提交 Lint 修复
48+
if: inputs.fix
49+
uses: EndBug/add-and-commit@v9
50+
with:
51+
message: 自动修改文件格式
52+
committer_name: GitHub Actions
53+
committer_email: actions@github.com

‎.github/workflows/main.yml‎

Lines changed: 0 additions & 28 deletions
This file was deleted.

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ package-lock.json
66
**/.vuepress/.cache/
77
**/.vuepress/.temp/
88
**/.vuepress/dist/
9+
**/.vitepress/cache
10+
**/.vitepress/dist
911
**/.obsidian

0 commit comments

Comments
 (0)