Skip to content

Commit 6621d57

Browse files
committed
build
1 parent 2b82443 commit 6621d57

File tree

2 files changed

+31
-18
lines changed

2 files changed

+31
-18
lines changed

.github/workflows/deploy.yml

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Deploy Hexo-theme-snippet to GitHub Pages
22

33
on:
44
push:
5-
branches: [dev] # 只在dev分支推送时触发
5+
branches: [dev]
66

77
jobs:
88
build-and-deploy:
@@ -12,12 +12,12 @@ jobs:
1212
- name: Checkout
1313
uses: actions/checkout@v4
1414
with:
15-
ref: dev # 明确指定检出dev分支
15+
ref: dev
1616

1717
- name: Setup Node.js
1818
uses: actions/setup-node@v3
1919
with:
20-
node-version: '20' # Hexo推荐使用Node.js 12+
20+
node-version: '20'
2121

2222
- name: Install Hexo and dependencies
2323
run: |
@@ -29,21 +29,34 @@ jobs:
2929
hexo clean
3030
hexo generate
3131
32-
# 部署到gh-pages分支
32+
- name: Update README with deployment info
33+
run: |
34+
time=$(date '+%Y-%m-%d %H:%M:%S')
35+
cat <<EOF >> README.md
36+
37+
## Deployment Information
38+
39+
部署状态 | 集成结果 | 参考值
40+
---|---|---
41+
完成时间 | $time | yyyy-mm-dd hh:mm:ss
42+
部署环境 | $RUNNER_OS + node-${{ env.npm_config_node_version }} | windows \| linux \| macos + node-version
43+
部署类型 | ${{ github.event_name }} | push \| pull_request \| workflow_dispatch
44+
仓库地址 | ${{ github.repository }} | owner_name/repo_name
45+
提交分支 | ${{ github.sha }} | commit hash
46+
提交信息 | ${{ github.event.head_commit.message }} |
47+
Workflow ID | ${{ github.run_id }} |
48+
Workflow NUM | ${{ github.run_number }} |
49+
EOF
50+
51+
git config --global user.name "GitHub Actions"
52+
git config --global user.email "actions@github.com"
53+
git add README.md
54+
git commit -m "Update README with deployment info" || echo "No changes to commit"
55+
git push
56+
3357
- name: Deploy to GitHub Pages
3458
uses: peaceiris/actions-gh-pages@v3
3559
with:
3660
github_token: ${{ secrets.GITHUB_TOKEN }}
37-
publish_dir: ./public # Hexo默认生成的静态文件目录
38-
publish_branch: gh-pages # 部署的目标分支
39-
40-
# 或者如果你想部署到main分支的docs文件夹
41-
# - name: Deploy to docs folder
42-
# run: |
43-
# mkdir -p docs
44-
# cp -r public/* docs/
45-
# git config --global user.name "GitHub Actions"
46-
# git config --global user.email "actions@github.com"
47-
# git add docs
48-
# git commit -m "Update GitHub Pages"
49-
# git push
61+
publish_dir: ./public
62+
publish_branch: gh-pages

source/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 91前端网
22

3-
[![Build Status](https://travis-ci.com/shenliyang/shenliyang.github.io.svg?branch=dev)](https://travis-ci.com/shenliyang/shenliyang.github.io)
3+
![Build Status](https://img.shields.io/github/actions/workflow/status/shenliyang/shenliyang.github.io/deploy.yml?label=Deployment)
44
[![ImgBot](https://img.shields.io/badge/ImgBot-build-brightgreen.svg)]()
55

66
## 使用Snippet 主题

0 commit comments

Comments
 (0)