Skip to content

update ox

update ox #23

Workflow file for this run

name: Deploy Hexo to GitHub Pages
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# 步骤 1:检出源代码
- name: Checkout Source Code
uses: actions/checkout@v3
# 步骤 2:设置 Node.js 环境
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16' # 根据你的项目需求选择 Node.js 版本
# 步骤 3:安装依赖
- name: Install Dependencies
run: npm install
# 步骤 4:生成 Hexo 静态文件
- name: Generate Hexo Site
run: |
npx hexo clean
npx hexo generate
# 步骤 5:检出目标仓库
- name: Checkout Target Repository
uses: actions/checkout@v3
with:
repository: TabNahida/TabNahida.github.io # 目标仓库
token: ${{ secrets.TARGET_REPO_TOKEN }} # 之前添加的 Secret
path: target-repo
# 步骤 6:复制生成的文件到目标仓库的 docs 文件夹
- name: Copy Files to Target Repository
run: |
rm -rf target-repo/docs/*
cp -R public/* target-repo/docs/
cp CNAME target-repo/docs/CNAME
# 步骤 7:提交并推送更改
- name: Commit and Push Changes
run: |
cd target-repo
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add docs
git commit -m "Update Hexo site" || echo "No changes to commit"
git push