Skip to content

Commit

Permalink
testtt
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhimingYe committed Dec 18, 2024
1 parent fefa378 commit d1e7d8a
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,39 @@ name: Deploy to gh-pages
on:
push:
branches:
- main # 触发条件:main分支更新时
- main # 触发此 Action的分支,设置为 main

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout main branch
uses: actions/checkout@v2
# Checkout main branch
- name: Checkout main branch
uses: actions/checkout@v2
with:
ref: main # 确保拉取 main 分支的内容

- name: Deploy to gh-pages
run: |
# 配置 Git 用户
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
# 设置 Git 用户
- name: Set up Git
run: |
git config user.name "github-actions"
git config user.email "github-[email protected]"
# Checkout gh-pages 分支
git fetch origin gh-pages || git checkout --orphan gh-pages
git reset --hard origin/gh-pages
# Checkout gh-pages branch
- name: Checkout gh-pages branch
run: |
git fetch origin gh-pages:gh-pages
git checkout gh-pages
# 复制 site/_site 目录的内容到 gh-pages 分支
cp -r site/_site/* .
# Copy _site folder content from main branch to gh-pages
- name: Copy _site to gh-pages
run: |
cp -r site/_site/* . # 将 _site 中的文件复制到当前目录(gh-pages)
# 提交并推送更新到 gh-pages 分支
git add .
git commit -m "Deploy _site to gh-pages"
git push origin gh-pages
# Add changes and commit them
- name: Commit and push changes
run: |
git add .
git commit -m "Deploy site to gh-pages"
git push origin gh-pages

0 comments on commit d1e7d8a

Please sign in to comment.