Skip to content

Commit bf0bee1

Browse files
committed
ci: 修文档站 base 路径 + 加 GitHub Pages 自动部署
setube.github.io/stackprism/ 上看不到样式的根因不是主题没生效,是 vitepress config 漏了 base,build 出来的 HTML 把所有 asset link 写成 /assets/style.xxx.css,部署到子路径 /stackprism/ 下时 / 是 setube.github.io 根目录,资源全部 404,浏览器拿不到 CSS / JS / 字体,整页只剩裸 HTML。 config 加 base: '/stackprism/' 后,build 产物里 href / src 全部变成 /stackprism/assets/...,跟实际部署路径对齐。验证:dist/index.html 第一行 href="/stackprism/assets/style.Bqr992fK.css"。 新建 .github/workflows/deploy-docs.yml:push 到 main 时如果 docs/ 或文档相关文件有改动则触发,跑 pnpm run docs:build 把 docs/.vitepress/dist 上传到 actions/upload-pages-artifact,再用 actions/deploy-pages@v4 发布。两阶段 job:build / deploy 分离,concurrency group 锁 pages 避免并发部署冲突。permissions 只给 pages: write + id-token: write 满足 Pages 部署,不开多余。也支持 workflow_dispatch 手动跑。 仓库需要在 Settings → Pages → Source 选「GitHub Actions」(不是 Deploy from a branch),第一次发布之后这条配置会持久化。 插件版本升级到 1.0.93。
1 parent b916aa1 commit bf0bee1

3 files changed

Lines changed: 69 additions & 1 deletion

File tree

.github/workflows/deploy-docs.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: 部署文档站到 GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'docs/**'
8+
- 'package.json'
9+
- 'pnpm-lock.yaml'
10+
- '.github/workflows/deploy-docs.yml'
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
concurrency:
19+
group: pages
20+
cancel-in-progress: false
21+
22+
jobs:
23+
build:
24+
name: 构建文档站
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: 检出仓库
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
- name: 安装 pnpm
33+
uses: pnpm/action-setup@v4
34+
with:
35+
version: 10
36+
37+
- name: 安装 Node
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: 20
41+
cache: pnpm
42+
43+
- name: 安装依赖
44+
run: pnpm install --frozen-lockfile
45+
46+
- name: 构建 VitePress
47+
run: pnpm run docs:build
48+
49+
- name: 配置 Pages
50+
uses: actions/configure-pages@v4
51+
52+
- name: 上传产物
53+
uses: actions/upload-pages-artifact@v3
54+
with:
55+
path: docs/.vitepress/dist
56+
57+
deploy:
58+
name: 部署到 GitHub Pages
59+
needs: build
60+
runs-on: ubuntu-latest
61+
environment:
62+
name: github-pages
63+
url: ${{ steps.deployment.outputs.page_url }}
64+
steps:
65+
- name: 部署
66+
id: deployment
67+
uses: actions/deploy-pages@v4

docs/.vitepress/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export default defineConfig({
44
lang: 'zh-CN',
55
title: 'StackPrism',
66
description: '网页技术栈检测扩展 · 使用文档',
7+
base: '/stackprism/',
78
lastUpdated: true,
89
head: [['meta', { name: 'theme-color', content: '#0f766e' }]],
910
themeConfig: {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "stackprism",
33
"private": true,
4-
"version": "1.0.92",
4+
"version": "1.0.93",
55
"type": "module",
66
"description": "StackPrism 用于检测网页前端、后端、CDN、SaaS、广告营销、统计、登录、支付、网站程序和主题模板线索。",
77
"scripts": {

0 commit comments

Comments
 (0)