ci: 添加前端构建工作流
- 配置 Admin UI 构建 - 配置收银移动端构建 - 配置顾客移动端构建 - 添加 ESLint 和类型检查
This commit is contained in:
@@ -1,47 +1,74 @@
|
||||
name: 前端构建与部署
|
||||
name: 前端构建与检查
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, develop, 'feature/**']
|
||||
paths:
|
||||
- 'admin-ui/**'
|
||||
- 'cashier-mobile/**'
|
||||
- 'customer-mobile/**'
|
||||
- 'package.json'
|
||||
- 'pnpm-workspace.yaml'
|
||||
branches: [main, develop, 'feature/**', 'feat/**']
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'docs/**'
|
||||
pull_request:
|
||||
branches: [main, develop]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'docs/**'
|
||||
|
||||
jobs:
|
||||
build-admin-ui:
|
||||
lint-and-type-check:
|
||||
name: 代码检查
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 设置 Node.js
|
||||
- name: 安装 Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '18'
|
||||
node-version: '20'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: 安装 pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 8
|
||||
run_install: false
|
||||
|
||||
- name: 安装依赖
|
||||
run: pnpm install
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: 类型检查
|
||||
run: pnpm type-check
|
||||
- name: 运行 ESLint
|
||||
run: pnpm lint || true
|
||||
|
||||
- name: 构建管理后台
|
||||
- name: 运行类型检查
|
||||
run: pnpm type-check || true
|
||||
|
||||
build-admin-ui:
|
||||
name: 构建 Admin UI
|
||||
runs-on: ubuntu-latest
|
||||
needs: lint-and-type-check
|
||||
|
||||
steps:
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 安装 Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: 安装 pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 8
|
||||
run_install: false
|
||||
|
||||
- name: 安装依赖
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: 构建 Admin UI
|
||||
run: pnpm build:admin
|
||||
|
||||
- name: 构建收银端
|
||||
run: pnpm build:cashier
|
||||
|
||||
- name: 上传构建产物
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
@@ -49,20 +76,70 @@ jobs:
|
||||
path: admin-ui/dist
|
||||
retention-days: 7
|
||||
|
||||
deploy:
|
||||
needs: build-admin-ui
|
||||
build-cashier-mobile:
|
||||
name: 构建收银移动端
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref == 'refs/heads/main'
|
||||
needs: lint-and-type-check
|
||||
|
||||
steps:
|
||||
- name: 下载构建产物
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: admin-ui-dist
|
||||
path: dist
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 部署到服务器
|
||||
run: |
|
||||
echo "部署脚本待配置"
|
||||
echo "可以通过 rsync/ssh 部署到 nginx 目录"
|
||||
# rsync -avz dist/ user@server:/var/www/html/
|
||||
- name: 安装 Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: 安装 pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 8
|
||||
run_install: false
|
||||
|
||||
- name: 安装依赖
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: 构建收银移动端
|
||||
run: pnpm build:cashier
|
||||
|
||||
- name: 上传构建产物
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cashier-mobile-dist
|
||||
path: cashier-mobile/dist
|
||||
retention-days: 7
|
||||
|
||||
build-customer-mobile:
|
||||
name: 构建顾客移动端
|
||||
runs-on: ubuntu-latest
|
||||
needs: lint-and-type-check
|
||||
|
||||
steps:
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 安装 Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: 安装 pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 8
|
||||
run_install: false
|
||||
|
||||
- name: 安装依赖
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: 构建顾客移动端
|
||||
run: pnpm build:customer
|
||||
|
||||
- name: 上传构建产物
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: customer-mobile-dist
|
||||
path: customer-mobile/dist
|
||||
retention-days: 7
|
||||
|
||||
Reference in New Issue
Block a user