mirror of
https://github.com/imsyy/home.git
synced 2025-05-20 05:00:14 +09:00
Update build.yml
This commit is contained in:
parent
ce10931a62
commit
49c3793f8b
25
.github/workflows/build.yml
vendored
25
.github/workflows/build.yml
vendored
@ -49,7 +49,7 @@ jobs:
|
||||
path: dist
|
||||
|
||||
deploy:
|
||||
name: Deploy to Branch
|
||||
name: Deploy to gh-pages
|
||||
runs-on: windows-latest
|
||||
needs: release # 依赖 release 任务完成
|
||||
steps:
|
||||
@ -64,19 +64,20 @@ jobs:
|
||||
name: Home
|
||||
path: dist
|
||||
|
||||
# 切换到目标分支(例如 gh-pages)
|
||||
- name: Checkout target branch
|
||||
# 切换到 gh-pages 分支
|
||||
- name: Checkout gh-pages branch
|
||||
run: |
|
||||
git fetch origin gh-pages:gh-pages
|
||||
git checkout gh-pages
|
||||
|
||||
# 清空目标分支的内容(可选)
|
||||
- name: Clean target branch
|
||||
# 删除 gh-pages 分支下的所有文件(除了 .git 目录)
|
||||
- name: Clean gh-pages branch
|
||||
run: |
|
||||
Remove-Item * -Recurse -Force -Exclude .git
|
||||
# 删除所有文件和文件夹,除了 .git
|
||||
Get-ChildItem -Path . -Exclude .git | Remove-Item -Recurse -Force
|
||||
|
||||
# 将构建产物复制到目标分支
|
||||
- name: Copy files to target branch
|
||||
# 将构建产物复制到 gh-pages 分支
|
||||
- name: Copy files to gh-pages branch
|
||||
run: |
|
||||
Copy-Item -Path dist/* -Destination . -Recurse -Force
|
||||
|
||||
@ -86,9 +87,9 @@ jobs:
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add .
|
||||
git commit -m "Deploy website from dev branch"
|
||||
git commit -m "Deploy website from dev branch (cleaned branch)"
|
||||
|
||||
# 推送到目标分支
|
||||
- name: Push to target branch
|
||||
# 推送到 gh-pages 分支
|
||||
- name: Push to gh-pages branch
|
||||
run: |
|
||||
git push origin gh-pages
|
||||
git push origin gh-pages --force
|
||||
|
Loading…
Reference in New Issue
Block a user