Skip to content

Commit 28972b4

Browse files
committed
build: enable auto deployment
1 parent d4a60be commit 28972b4

File tree

3 files changed

+73
-5
lines changed

3 files changed

+73
-5
lines changed

.github/workflows/deploy.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Deploy Hexo site to Pages
2+
3+
on:
4+
# Runs on pushes targeting the `master` branch
5+
push:
6+
branches: [master]
7+
8+
# Allows manual trigger from the Actions tab
9+
workflow_dispatch:
10+
11+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
# Allow only one concurrent deployment, skipping queued runs
18+
concurrency:
19+
group: pages
20+
cancel-in-progress: false
21+
22+
jobs:
23+
# Build job
24+
build:
25+
runs-on: ubuntu-latest
26+
steps:
27+
# Check out the code
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
# Set up Node.js environment
32+
- name: Setup Node
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: 'lts/*'
36+
cache: npm
37+
38+
# Install dependencies
39+
- name: Install dependencies
40+
run: |
41+
npm install
42+
npm install -g hexo-cli
43+
npm install hexo-theme-stellar
44+
npm audit fix
45+
46+
# Generate static files with Hexo
47+
- name: Build with Hexo
48+
run: hexo generate
49+
50+
# Upload artifact
51+
- name: Upload artifact
52+
uses: actions/upload-pages-artifact@v3
53+
with:
54+
path: ./public
55+
56+
# Deployment job
57+
deploy:
58+
environment:
59+
name: github-pages
60+
url: ${{ steps.deployment.outputs.page_url }}
61+
needs: build
62+
runs-on: ubuntu-latest
63+
name: Deploy
64+
steps:
65+
- name: Deploy to GitHub Pages
66+
id: deployment
67+
uses: actions/deploy-pages@v4

README.md

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

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

1816
```
1917
npm i hexo-theme-stellar
2018
npm audit fix
2119
```
2220

23-
24-
2521
最后按照Hexo的正常逻辑生成并本地启动即可。
2622

2723
```
2824
hexo g
2925
hexo s
3026
```
3127

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

package-lock.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)