-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
17 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 |