Skip to content

test3

test3 #4

Workflow file for this run

name: Deploy to gh_pages
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# 检出 main 分支的代码
- name: Checkout main branch
uses: actions/checkout@v3
with:
fetch-depth: 0
# 设置 Git 用户信息
- name: Set up Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# 复制 site/_site 内容到临时目录
- name: Copy _site content
run: |
mkdir temp
cp -r site/_site/* temp/
# 检出 gh_pages 分支
- name: Checkout gh_pages branch
run: |
git checkout gh_pages
# 将临时目录内容覆盖到当前分支
- name: Overwrite gh_pages with _site
run: |
rm -rf *
cp -r temp/* .
# 添加所有更改
- name: Add changes
run: git add --all
# 提交更改
- name: Commit changes
run: |
git commit -m "Update gh_pages with latest _site" || echo "No changes to commit"
# 强制推送到 gh_pages 分支
- name: Push to gh_pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git push origin gh_pages --force