Skip to content

Commit 60c02e3

Browse files
committed
feat(scripts): add auto-deployment script
1 parent 18586e6 commit 60c02e3

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

.github/workflows/deploy.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Deploy Website
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build-and-deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
# 检出代码
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
# 设置 Node.js 环境
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v3
20+
with:
21+
node-version: 'lts/*'
22+
23+
# 安装依赖
24+
- name: Install dependencies
25+
run: |
26+
npm install
27+
npm install hexo-theme-stellar
28+
npm audit fix
29+
30+
# 生成静态文件
31+
- name: Generate static files
32+
run: hexo generate
33+
34+
# 部署到 GitHub Pages
35+
- name: Deploy to GitHub Pages
36+
uses: peaceiris/actions-gh-pages@v3
37+
with:
38+
github_token: ${{ secrets.GITHUB_TOKEN }}
39+
publish_dir: ./public

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,21 @@ node: 14.17.3 ~ 20.10.0 # 建议选择 LTS 版本,过高的版本 hexo 还
1111
npm: 6.14.13 ~ 10.2.3
1212
```
1313

14-
1514
之后在`_config.yml`所在文件夹安装hexo-stellar(如果存在包问题则使用`npm audit fix`修复):
1615

1716
```
1817
npm i hexo-theme-stellar
1918
npm audit fix
2019
```
2120

22-
23-
2421
最后按照Hexo的正常逻辑生成并本地启动即可。
2522

2623
```
2724
hexo g
2825
hexo s
2926
```
3027

28+
## 自动化部署(GitHub Actions)
29+
30+
项目已配置 GitHub Actions 自动化部署。当代码推送到 `main` 分支时,GitHub Actions 会自动生成静态文件并部署到 GitHub Pages.
31+

0 commit comments

Comments
 (0)