Skip to content
This repository was archived by the owner on Jun 30, 2024. It is now read-only.

迁移workflow

迁移workflow #1

Workflow file for this run

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 fetch && gitbook install && 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]"
# 创建一个新分支,如果已存在则切换到该分支
git checkout main || git checkout -b 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 "Deploy GitBook to main branch"
# 推送到远程 main 分支
git push origin main