一、思路
- 仓库一:wztlink1013.github.io【master】
- 仓库二:test【gh-pages】
将test仓库下gh-pages分支下的所有文件复制到文件夹test,在wztlink1013.github.io仓库下clone到文件夹wztlink1013.github.io中,进入wztlink1013.github.io文件夹,然后通过命令将test文件夹复制到wztlink1013文件夹中,最后push到wztlink1013.github.io仓库中。
二、编写脚本
git config --global user.name 'wztlink1013'
git config --global user.email 'wztlink1013@163.com'
git clone https://github.com/wztlink1013/test.git
git clone https://github.com/wztlink1013/wztlink1013.github.io.git
cd wztlink1013.github.io
mkdir test
cd ..
xcopy .\test .\wztlink1013.github.io /e
cd wztlink1013.github.io
git status
git add .
git commit -m "add gh-pages files"
git push "https://${Github_Token}@github.com/wztlink1013/wztlink1013.github.io" master:master
三、编写GitHub Actions
name: CI for wztlink1013.github.io
on: [push, watch]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: 配置Git
run: |
git config --global user.name 'wztlink1013'
git config --global user.email 'wztlink1013@163.com'
- name: 在云端进行复制文件夹操作
env:
Github_Token: ${{ secrets.TOKEN_GITHUBAPI }}
run: |
git clone https://github.com/wztlink1013/visualization visualization
git clone https://github.com/wztlink1013/wztlink1013.github.io .github_pages
cd visualization
rm -r .git
rm -r .github
cd ..
cd .github_pages
rm -r visualization
cd ..
mv visualization/ -f .github_pages/
cd .github_pages
git status
git add .
git commit -m "add gh-pages files"
git push --force --quiet "https://${Github_Token}@github.com/wztlink1013/wztlink1013.github.io" master:master