-
Notifications
You must be signed in to change notification settings - Fork 3
53 lines (43 loc) · 1.28 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: CI Workflow
on:
push:
branches:
- master
pull_request:
branches:
- master
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # 确保拉取完整的提交历史
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20' # 修改为 Node.js 20
- name: Install dependencies
run: npm ci # 使用 ci 命令清理并安装依赖,确保是最新的
- name: Build project
run: npm run build
- name: List build output
run: ls -R docs # 检查 docs 目录是否存在并列出内容
- name: Verify docs directory exists
run: |
if [ ! -d "docs" ]; then
echo "docs directory not found."
exit 1
fi
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages # 部署到 gh-pages 分支
folder: docs # 确保你要部署的文件夹
clean: true # 清理旧的部署文件
token: ${{ secrets.ACCESS_TOKEN }} # 使用 Access Token 进行身份验证