Skip to content
This repository has been archived by the owner on Jan 20, 2025. It is now read-only.

feat: 工作流

feat: 工作流 #24

name: pages-build-site
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 20
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 9
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Build docs
run: pnpm run build
- name: Remove all files except doc_build
run: |
# 删除除了 doc_build 文件夹之外的所有文件和文件夹
rm -rf $(ls -A | grep -v doc_build)
- name: Move doc_build contents to root and remove doc_build folder
run: |
# 将 doc_build 文件夹中的内容移动到根目录
mv doc_build/* .
# 删除空的 doc_build 文件夹
rm -rf doc_build
- name: Create and push to new branch
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
run: |
# 设置 Git 用户信息
git config --global user.name "Manshawar"
git config --global user.email "[email protected]"
git checkout --orphan doc_build
git add .
git commit -m "Generated documentation"
git push origin doc_build --force