1
0
mirror of https://github.com/142vip/408CSFamily.git synced 2026-02-02 18:20:26 +08:00

perf(GitHub Actions): 优化CD流水线,替换github pages部署流程

This commit is contained in:
142vip.cn
2024-09-24 14:32:33 +08:00
parent 1f0193aa56
commit cd99f58f49

View File

@@ -31,66 +31,37 @@ jobs:
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
fetch-depth: 0
## 安装PNPM
# 安装PNPM
- name: PNPM Install
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
with:
version: 8
version: 9.6.0
## 安装Node环境
# 安装Node环境
- name: Install Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.18.0
## 淘宝镜像加速
registry-url: 'https://registry.npmmirror.com'
## 缓存
cache: 'pnpm'
node-version: 20.16.0
# 缓存
cache: pnpm
## 下载依赖,并执行初始化脚本:钩子函数、思维导图构建
- name: Install Dependencies
run: |
./scripts/ci
# 运行构建脚本
- name: Build VuePress Site
run: |
./scripts/bundle build_proxy
# 编译 打包成dist
- name: Build with VitePress
run: pnpm build:proxy
# 将README.md同步利于github pages分支展示
- name: Add Readme.md To Dist
run: |
cp -f README.md docs/.vuepress/dist
- name: Check GitHub Pages status
uses: crazy-max/ghaction-github-status@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
pages_threshold: major_outage
path: docs/.vuepress/dist
## 获取Git提交信息
- name: Get Commit Info
id: gitInfo
run: |
echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
echo "author=$(git log -1 --pretty=%an)" >> $GITHUB_OUTPUT
echo "email=$(git log -1 --pretty=%ae)" >> $GITHUB_OUTPUT
## 参考https://github.com/marketplace/actions/github-pages
- name: Deploy To GitHub Page
uses: crazy-max/ghaction-github-pages@v3
with:
target_branch: pages/github
build_dir: docs/.vuepress/dist
commit_message: |
chore(sync): v${{steps.gitInfo.outputs.version}}
部署地址: https://142vip.github.io/408CSFamily
committer: ${{steps.gitInfo.outputs.author}}<${{steps.gitInfo.outputs.email}}>
author: Mr·Sync
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# 部署
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
## 部署到vercel平台
deploy-vercel:
@@ -205,4 +176,4 @@ jobs:
# echo "-----------正在运行的服务--------"
# docker ps
# cd /service_env/ && git reset --hard && git pull origin main
# bash ./scripts/book_doc.deploy.sh jsc ${{steps.version.outputs.value}}
# bash ./scripts/book_doc.deploy.sh jsc ${{steps.version.outputs.value}}