Skip to content

Commit f94ef7d

Browse files
author
yinxiangzheng3
committed
docs: 配置 GitHub Pages 自动部署
1 parent cb2431e commit f94ef7d

2 files changed

Lines changed: 68 additions & 1 deletion

File tree

.github/workflows/deploy-docs.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Deploy Docs to GitHub Pages
2+
3+
on:
4+
# 推送到 main 分支且改动了官网内容时触发
5+
push:
6+
branches: [main]
7+
paths:
8+
- 'website/**'
9+
- '.github/workflows/deploy-docs.yml'
10+
# 允许在 Actions 页面手动触发
11+
workflow_dispatch:
12+
13+
# 授予 GITHUB_TOKEN 部署 Pages 所需权限
14+
permissions:
15+
contents: read
16+
pages: write
17+
id-token: write
18+
19+
# 只保留一个并发部署,跳过排队中的旧任务
20+
concurrency:
21+
group: pages
22+
cancel-in-progress: false
23+
24+
jobs:
25+
build:
26+
runs-on: ubuntu-latest
27+
defaults:
28+
run:
29+
working-directory: website
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0 # 拉取完整历史,供 lastUpdated 生成时间
35+
36+
- name: Setup Node
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version: 20
40+
41+
- name: Install dependencies
42+
run: npm install
43+
44+
- name: Build with VitePress
45+
run: npm run build
46+
47+
- name: Setup Pages
48+
uses: actions/configure-pages@v5
49+
50+
- name: Upload artifact
51+
uses: actions/upload-pages-artifact@v3
52+
with:
53+
path: website/.vitepress/dist
54+
55+
deploy:
56+
needs: build
57+
runs-on: ubuntu-latest
58+
environment:
59+
name: github-pages
60+
url: ${{ steps.deployment.outputs.page_url }}
61+
steps:
62+
- name: Deploy to GitHub Pages
63+
id: deployment
64+
uses: actions/deploy-pages@v4

website/.vitepress/config.mts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ export default defineConfig({
66
description: '代码知识图谱构建工具 — 解析 → 语义化 → 向量化',
77
appearance: 'dark',
88

9+
// 项目页部署到 https://ychangqing.github.io/IGraph/,需设置仓库名作为 base
10+
base: '/IGraph/',
11+
912
head: [
1013
['link', { rel: 'icon', href: '/logo.svg' }],
1114
],
@@ -119,7 +122,7 @@ export default defineConfig({
119122
},
120123

121124
socialLinks: [
122-
{ icon: 'github', link: 'https://github.com/' },
125+
{ icon: 'github', link: 'https://github.com/Ychangqing/IGraph' },
123126
],
124127

125128
footer: {

0 commit comments

Comments
 (0)