This repository was archived by the owner on Jun 30, 2024. It is now read-only.
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: Build Wiki and Deploy to Main | |
on: | |
push: | |
branches: | |
- wiki # 触发条件,当 wiki 分支有 push 事件时触发 | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest # 运行环境 | |
steps: | |
- name: Checkout Wiki Branch | |
uses: actions/checkout@v2 | |
with: | |
ref: wiki # 检出 wiki 分支 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '10' # 选择 Node.js 版本 | |
- name: Install GitBook | |
run: npm install -g gitbook-cli # 安装 GitBook CLI | |
- name: Build GitBook | |
run: gitbook build . # 构建 GitBook 静态文件 | |
- name: Deploy to Main Branch | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
# 切换到 main 分支 | |
git checkout main | |
# 确保 source/wiki 目录存在 | |
mkdir -p source/wiki | |
# 清除 source/wiki 目录下的内容 | |
rm -rf source/wiki/* | |
# 复制构建的静态文件到 source/wiki 目录 | |
cp -r _book/* source/wiki/ | |
# 添加所有文件到 git | |
git add source/wiki | |
# 提交更改 | |
git commit -m "Update wiki static pages" | |
# 推送到远程 main 分支 | |
git push origin main |