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