Skip to content

Merge pull request #42 from 142vip/feat/remove-lerna #90

Merge pull request #42 from 142vip/feat/remove-lerna

Merge pull request #42 from 142vip/feat/remove-lerna #90

Workflow file for this run

#
# CD持续交付
# - 部署到Github Pages
# - 发布新的Github Release
# 参考
# - https://vitepress.dev/zh/guide/deploy#github-pages
#
name: CD
on:
push:
branches:
- next
workflow_dispatch:
# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
permissions:
contents: read
pages: write
id-token: write
jobs:
# 版本发布
release:
name: 创建Github发布
runs-on: ubuntu-latest
# 主库next且执行release更新时执行
if: github.repository == '142vip/core-x' && startsWith(github.event.head_commit.message, 'chore(release):')
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
persist-credentials: false
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
fetch-depth: 0
# 安装PNPM
- name: PNPM Install
uses: pnpm/action-setup@v4
with:
version: 9.6.0
# 安装Node环境
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20.12.2
# 淘宝镜像加速
registry-url: 'https://registry.npmmirror.com'
# 缓存
cache: pnpm
# 下载依赖,并执行初始化脚本:钩子函数、思维导图构建
- name: Install Dependencies
run: |
./scripts/ci
- name: Build All Packages
run: |
pnpm build
# Github发布版本,并更新Release信息
- name: Release New Version
run: npx changelog
env:
GITHUB_TOKEN: ${{secrets.TOKEN}}
# 构建并部署Dist
deploy-dist:
name: 部署到Github Pages
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
if: github.repository == '142vip/core-x'
steps:
# 拉取代码
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # 如果未启用 lastUpdated,则不需要
# 安装pnpm
- name: PNPM Install
uses: pnpm/action-setup@v4
with:
version: 9.6.0
# 安装Node
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.12.2
cache: pnpm
registry-url: https://registry.npmmirror.com
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Install dependencies
run: |
./scripts/ci
# 编译 打包成dist
- name: Build with VitePress
run: pnpm build:docs
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: dist
# 部署
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4