Skip to content

Commit 4119ef7

Browse files
committed
Add GitHub Pages deployment
1 parent 614af6a commit 4119ef7

File tree

6 files changed

+109
-177
lines changed

6 files changed

+109
-177
lines changed

.github/workflows/deploy.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- master # 当推送到 master 分支时触发
7+
workflow_dispatch: # 允许手动触发
8+
9+
# 设置 GITHUB_TOKEN 的权限
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
15+
# 只允许一个并发部署
16+
concurrency:
17+
group: "pages"
18+
cancel-in-progress: false
19+
20+
jobs:
21+
build:
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: '18'
32+
33+
- name: Setup pnpm
34+
uses: pnpm/action-setup@v4
35+
with:
36+
version: 8
37+
38+
- name: Get pnpm store directory
39+
shell: bash
40+
run: |
41+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
42+
43+
- name: Setup pnpm cache
44+
uses: actions/cache@v4
45+
with:
46+
path: ${{ env.STORE_PATH }}
47+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
48+
restore-keys: |
49+
${{ runner.os }}-pnpm-store-
50+
51+
- name: Install dependencies
52+
run: pnpm install --frozen-lockfile
53+
54+
- name: Build
55+
run: pnpm build
56+
env:
57+
GITHUB_PAGES: true
58+
59+
- name: Setup Pages
60+
uses: actions/configure-pages@v4
61+
62+
- name: Upload artifact
63+
uses: actions/upload-pages-artifact@v3
64+
with:
65+
path: './build'
66+
67+
deploy:
68+
environment:
69+
name: github-pages
70+
url: ${{ steps.deployment.outputs.page_url }}
71+
runs-on: ubuntu-latest
72+
needs: build
73+
steps:
74+
- name: Deploy to GitHub Pages
75+
id: deployment
76+
uses: actions/deploy-pages@v4

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,37 @@ Run ESLint to check code quality:
8888
pnpm lint
8989
```
9090

91+
## 🚀 Deployment
92+
93+
### Deploy to GitHub Pages
94+
95+
This project is configured to automatically deploy to GitHub Pages using GitHub Actions.
96+
97+
#### Setup
98+
99+
1. Go to your repository **Settings****Pages**
100+
2. Under **Source**, select **GitHub Actions**
101+
3. Push to the `master` branch or manually trigger the workflow
102+
103+
The site will be available at: `https://marktext.github.io/website/`
104+
105+
#### Manual Deployment
106+
107+
You can also trigger the deployment manually:
108+
109+
1. Go to **Actions** tab in your GitHub repository
110+
2. Select **Deploy to GitHub Pages** workflow
111+
3. Click **Run workflow**
112+
113+
#### Local Preview of Production Build
114+
115+
To preview the production build locally before deploying:
116+
117+
```bash
118+
pnpm build
119+
pnpm preview
120+
```
121+
91122
## 📁 Project Structure
92123

93124
```

package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@
33
"version": "1.0.0",
44
"private": true,
55
"type": "module",
6-
"homepage": "http://marktext.github.io/website",
76
"scripts": {
87
"dev": "vite",
98
"build": "tsc && vite build",
109
"preview": "vite preview",
1110
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
12-
"type-check": "tsc --noEmit",
13-
"predeploy": "npm run build",
14-
"deploy": "gh-pages -d build"
11+
"type-check": "tsc --noEmit"
1512
},
1613
"dependencies": {
1714
"axios": "^1.6.0",
1815
"dompurify": "^3.0.6",
1916
"fuzzaldrin": "^2.1.0",
20-
"gh-pages": "^6.3.0",
2117
"github-markdown-css": "^5.8.1",
2218
"html-tags": "3.3.1",
2319
"katex": "^0.16.9",

0 commit comments

Comments
 (0)