-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (47 loc) · 1.68 KB
/
ci.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
54
55
56
57
name: ci
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '21.6.1' # 或者你需要的其他版本
- name: Install dependencies
run: npm install
- name: Run Webpack build
run: npm run produce # 运行你在 package.json 中定义的生产打包命令
- name: List public directory
run: ls -R public || echo "public directory does not exist"
- name: Deploy to GitHub Pages
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
git checkout gh-pages || git checkout --orphan gh-pages
rm -rf *
if [ -d public ]; then
cp -R public/* .
else
echo "public directory does not exist"
exit 1
fi
git add .
git commit -m "Deploy to GitHub Pages" || echo "No changes to commit"
git push origin gh-pages
# - name: Clean public folder
# run: rm -rf ./public/* # 删除 public 文件夹中的所有内容
# - name: Copy build output to public folder
# run: cp -R ./dist/* ./public/ # 假设打包输出在 dist 文件夹
# - name: Deploy to GitHub Pages
# run: npm run gh-pages
# 这里替换为你的部署命令