基于平台选择定义部署策略:
前端部署:
npm run builddist/后端部署:
npm run build# .github/workflows/ci.yaml
name: CI Pipeline
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run type check
run: npm run type-check
- name: Run linting
run: npm run lint
- name: Run tests
run: npm run test
build:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build applications
run: npm run build
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: |
apps/admin/dist
apps/api/dist
| 环境 | 前端URL | 后端URL | 用途 |
|---|---|---|---|
| 开发 | http://localhost:3000 | http://localhost:8080 | 本地开发 |
| 测试 | http://test.example.com | http://api.test.example.com | 预生产测试 |
| 生产 | http://app.example.com | http://api.example.com | 生产环境 |