This repository was archived by the owner on Jun 30, 2024. It is now read-only.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/* . | |
# 添加所有文件到 git | |
git add . | |
# 提交更改 | |
git commit -m "Update HTML branch with latest build" | |
# 推送到远程 HTML 分支 | |
git push origin HTML --force |