Skip to content
This repository was archived by the owner on Jun 30, 2024. It is now read-only.

修改页面

修改页面 #22

name: Hexo Deploy to HTML Branch
on:
push:
branches:
- main # 触发条件,当 main 分支有 push 事件时触发
jobs:
build-and-deploy:
runs-on: ubuntu-latest # 运行环境
steps:
- name: Checkout Source
uses: actions/checkout@v2 # 检出代码
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20' # 选择 Node.js 版本
- name: Install Dependencies
run: npm install # 安装 Hexo 依赖
- name: Hexo Generate
run: npm run build # 构建 Hexo 静态文件
- name: Deploy to HTML Branch
run: |
# 配置 git 用户信息
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
# 切换到 HTML 分支
git checkout -b HTML
# 清除当前分支内容
git rm -rf .
# 复制生成的静态文件到 HTML 分支
cp -r ./public/* .
# 删除资源镜像保证Cf Pages成功推送
rm -f files/mirror/*.zip
# 添加所有文件到 git
git add .
# 提交更改
git commit -m "Update HTML branch with latest build"
# 推送到远程 HTML 分支
git push origin HTML --force