Skip to content

Commit d6afe32

Browse files
committed
feat: 迁移 GitHub Pages 部署至 kimi-cli 框架
- 重构 workflow 为单 job 结构 (build + deploy 合并) - 新增 actions/configure-pages@v5 自动配置 - 支持动态 VITEPRESS_BASE 环境变量设置 - 添加 .nojekyll 文件生成 - 优化 VitePress base 配置支持环境变量 遵循 kimi-cli 项目的 Pages 部署最佳实践
1 parent dd55266 commit d6afe32

2 files changed

Lines changed: 28 additions & 13 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,40 +22,55 @@ concurrency:
2222
group: pages
2323
cancel-in-progress: false
2424

25-
env:
26-
NODE_VERSION: 20
27-
2825
jobs:
29-
build:
26+
deploy:
3027
runs-on: ubuntu-latest
28+
environment:
29+
name: github-pages
30+
url: ${{ steps.deployment.outputs.page_url }}
3131
steps:
3232
- name: Checkout
3333
uses: actions/checkout@v4
3434

3535
- name: Setup Node.js
3636
uses: actions/setup-node@v4
3737
with:
38-
node-version: ${{ env.NODE_VERSION }}
38+
node-version: "20"
3939
cache: npm
4040

41+
- name: Configure GitHub Pages
42+
id: pages
43+
uses: actions/configure-pages@v5
44+
45+
- name: Set VitePress base
46+
shell: bash
47+
env:
48+
BASE_PATH: ${{ steps.pages.outputs.base_path }}
49+
run: |
50+
set -euo pipefail
51+
if [[ -z "${BASE_PATH}" ]]; then
52+
base="/"
53+
else
54+
base="${BASE_PATH%/}/"
55+
fi
56+
echo "VITEPRESS_BASE=${base}" >> "$GITHUB_ENV"
57+
4158
- name: Install dependencies
4259
run: npm ci
4360

4461
- name: Build for deployment
62+
env:
63+
VITEPRESS_BASE: ${{ env.VITEPRESS_BASE }}
4564
run: npm run build:ci
4665

66+
- name: Add .nojekyll
67+
run: touch .vitepress/dist/.nojekyll
68+
4769
- name: Upload Pages artifact
4870
uses: actions/upload-pages-artifact@v3
4971
with:
5072
path: .vitepress/dist
5173

52-
deploy:
53-
needs: build
54-
runs-on: ubuntu-latest
55-
environment:
56-
name: github-pages
57-
url: ${{ steps.deployment.outputs.page_url }}
58-
steps:
5974
- name: Deploy to GitHub Pages
6075
id: deployment
6176
uses: actions/deploy-pages@v4

.vitepress/config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { sidebarZh } from './config/sidebar.js';
55
export default defineConfig({
66
title: 'Awesome Cursor Rules',
77
description: '为中文开发者打造的 Cursor AI 编程规则集合',
8-
base: '/awesome-cursorrules-zh/',
8+
base: process.env.VITEPRESS_BASE || '/awesome-cursorrules-zh/',
99
lang: 'zh-CN',
1010

1111
themeConfig: {

0 commit comments

Comments
 (0)