Skip to content

Commit cb7de97

Browse files
authored
Add GitHub Actions workflow for Hexo deployment
This GitHub Actions workflow automates the deployment of a Hexo site to GitHub Pages upon pushes to the main branch. It includes steps for checking out the code, installing Node.js and Hexo, generating static files, and uploading the build artifacts.
1 parent 682643e commit cb7de97

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,55 @@
11

2+
name: Hexo Deploy
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: "pages"
16+
cancel-in-progress: true
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout 源码
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: 安装 Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: '20'
31+
cache: 'npm'
32+
33+
- name: 安装 Hexo 和依赖
34+
run: |
35+
npm install -g hexo-cli
36+
npm install
37+
38+
- name: 生成静态文件 (Hexo Generate)
39+
run: hexo generate
40+
41+
- name: 上传构建产物
42+
uses: actions/upload-pages-artifact@v3
43+
with:
44+
path: ./public
45+
46+
deploy:
47+
environment:
48+
name: github-pages
49+
url: ${{ steps.deployment.outputs.page_url }}
50+
runs-on: ubuntu-latest
51+
needs: build
52+
steps:
53+
- name: 发布到 GitHub Pages
54+
id: deployment
55+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)