-
Notifications
You must be signed in to change notification settings - Fork 4
156 lines (135 loc) · 5.11 KB
/
deploy.yml
File metadata and controls
156 lines (135 loc) · 5.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: deploy
on:
# 每当 push 到 docs 分支时触发部署
# Deployment is triggered whenever a push is made to the docs branch.
push:
branches: [docs]
# 手动触发部署
# Manually trigger deployment
workflow_dispatch:
jobs:
docs:
runs-on: ubuntu-latest
permissions:
id-token: write # Needed for auth with Deno Deploy
contents: read # Needed to clone the repository
steps:
- uses: actions/checkout@v4
with:
# "最近更新时间" 等 git 日志相关信息,需要拉取全部提交记录
# "Last updated time" and other git log-related information require fetching all commit records.
fetch-depth: 0
# 克隆 Karin 源码仓库
# Clone Karin source repository
- name: Checkout Karin source
uses: actions/checkout@v4
with:
repository: KarinJS/Karin
path: karin-source
fetch-depth: 1
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
# 选择要使用的 node 版本
node-version: 22
# 安装 Karin 源码依赖并生成 TypeDoc
# Install Karin source dependencies and generate TypeDoc
- name: Install Karin dependencies and generate docs
run: |
cd karin-source
pnpm install --frozen-lockfile
cd packages/core
pnpm run docs:build
# 复制生成的 TypeDoc 到文档项目
# Copy generated TypeDoc to docs project
- name: Copy TypeDoc to docs project
run: |
# 删除旧的 types 目录
rm -rf docs/guide/api/types
# 复制新生成的文档
cp -r karin-source/packages/core/guide/api/types docs/guide/api/
# 复制 typedoc-sidebar.json 到 VuePress collections 目录
cp karin-source/packages/core/guide/api/types/typedoc-sidebar.json docs/.vuepress/collections/typedoc-sidebar.json
# 清理源码目录
rm -rf karin-source
# 安装依赖
# Install dependencies
- name: Install Dependencies
run: pnpm install --frozen-lockfile
# 运行构建脚本
# Run the build script
- name: Build VuePress site
run: pnpm run build
# 将docs/CNAME文件复制到docs/.vuepress/dist目录下
- name: Copy CNAME
run: cp docs/CNAME docs/.vuepress/dist/CNAME
# 查看 workflow 的文档来获取更多信息
# @see https://github.com/crazy-max/ghaction-github-pages
- name: Deploy to GitHub Pages
uses: crazy-max/ghaction-github-pages@v4
with:
# 部署到 gh-pages 分支
target_branch: gh-pages
# 部署目录为 VuePress 的默认输出目录
build_dir: docs/.vuepress/dist
env:
# @see https://docs.github.com/cn/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
GITHUB_TOKEN: ${{ secrets.DOCS_TOKEN }}
# rm CNAME
- name: Remove CNAME
run: rm -f docs/.vuepress/dist/CNAME
- name: Install Deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Upload to Deno Deploy
uses: denoland/deployctl@v1
with:
project: karin
entrypoint: https://deno.land/std@0.217.0/http/file_server.ts
root: docs/.vuepress/dist
# # cp vercel.json
# - name: cp vercel.json
# run: cp vercel.json docs/.vuepress/dist/vercel.json
- name: Push to hanhan0258/karin-docs
id: push-to-hanhan
uses: peaceiris/actions-gh-pages@v3
continue-on-error: true
with:
personal_token: ${{ secrets.HANHAN_PUSH }}
external_repository: hanhan0258/karin-docs
publish_branch: gh-pages
publish_dir: docs/.vuepress/dist
force: true
force_orphan: true
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
- name: Check hanhan0258/karin-docs push status
if: steps.push-to-hanhan.outcome == 'failure'
run: |
echo "::error::推送到 hanhan0258/karin-docs 仓库失败"
echo "错误信息: ${{ steps.push-to-hanhan.outputs.error }}"
- name: Push to yusheng929/karin-docs
id: push-to-yusheng
uses: peaceiris/actions-gh-pages@v3
continue-on-error: true
with:
personal_token: ${{ secrets.YUSHENG }}
external_repository: yusheng929/karin-docs
publish_branch: gh-pages
publish_dir: docs/.vuepress/dist
force: true
force_orphan: true
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
- name: Check yusheng929/karin-docs push status
if: steps.push-to-yusheng.outcome == 'failure'
run: |
echo "::error::推送到 yusheng929/karin-docs 仓库失败"
echo "错误信息: ${{ steps.push-to-yusheng.outputs.error }}"