Update autobuild.yml #6
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
name: Deploy Pages | |
on: | |
push: | |
branches: | |
- main # 监听 main 分支的提交 | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout main branch | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
- name: Install dependencies | |
run: npm install | |
- name: Build | |
run: npm run build # 这会生成 docs 目录 | |
- name: Checkout gh-pages branch | |
uses: actions/checkout@v4 | |
with: | |
ref: gh-pages | |
path: gh-pages | |
- name: Copy docs to gh-pages directory | |
run: | | |
rm -rf gh-pages/* | |
cp -r docs/* gh-pages/ | |
- name: Commit and push to gh-pages | |
working-directory: gh-pages | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "GitHub Action" | |
git add . | |
git commit -m "Update documentation" -a || echo "No changes to commit" | |
git push --force origin gh-pages |