Skip to content

Commit f6659ba

Browse files
chore: deploy docs to GitHub Pages via Actions
为 GitHub Pages 子路径 /Mp2RSS/ 适配 base 与 head 图标链接, 并新增 deploy.yml,在 push 到 main 时用 pnpm 构建后自动发布。
1 parent 2fe89f6 commit f6659ba

2 files changed

Lines changed: 62 additions & 3 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Deploy VitePress site to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: pages
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Setup pnpm
27+
uses: pnpm/action-setup@v4
28+
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: 20
33+
cache: pnpm
34+
35+
- name: Install dependencies
36+
run: pnpm install --frozen-lockfile
37+
38+
- name: Build with VitePress
39+
run: pnpm build
40+
41+
- name: Setup Pages
42+
uses: actions/configure-pages@v5
43+
44+
- name: Upload artifact
45+
uses: actions/upload-pages-artifact@v3
46+
with:
47+
path: .vitepress/dist
48+
49+
deploy:
50+
needs: build
51+
runs-on: ubuntu-latest
52+
environment:
53+
name: github-pages
54+
url: ${{ steps.deployment.outputs.page_url }}
55+
steps:
56+
- name: Deploy to GitHub Pages
57+
id: deployment
58+
uses: actions/deploy-pages@v4

.vitepress/config.mts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { defineConfig } from "vitepress";
22

3+
const base = "/Mp2RSS/";
34
const GOOGLE_ANALYTICS_ID = process.env.GOOGLE_ANALYTICS_ID || "";
45
const gaHead = GOOGLE_ANALYTICS_ID
56
? ([
@@ -28,11 +29,11 @@ export default defineConfig({
2829
srcDir: "docs",
2930
title: "Mp2RSS",
3031
description: "让订阅微信公众号像订阅播客一样顺畅",
31-
base: "/",
32+
base,
3233
lastUpdated: true,
3334
head: [
34-
["link", { rel: "icon", href: "/favicon.ico" }],
35-
["link", { rel: "apple-touch-icon", href: "/apple-touch-icon.png" }],
35+
["link", { rel: "icon", href: `${base}favicon.ico` }],
36+
["link", { rel: "apple-touch-icon", href: `${base}apple-touch-icon.png` }],
3637
...gaHead,
3738
],
3839
themeConfig: {

0 commit comments

Comments
 (0)