- ci-ts.yml: lint/typecheck/test/build + arch-scan + docker-build(classes + teacher-portal) - ci-go.yml: vet/build/test + docker-build(api-gateway) - ci-proto.yml: buf lint + buf breaking(本地 .git 比较) - docker.yml: main/tag 触发,构建推送 3 服务镜像到 Gitea Registry - deploy.yml: workflow_dispatch + workflow_run 触发,Runner 直接 docker compose 部署,含健康检查与回滚 - 所有 workflow runs-on: ubuntu-latest 匹配 actrunner 标签
96 lines
2.5 KiB
YAML
96 lines
2.5 KiB
YAML
name: CI TypeScript
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- 'services/classes/**'
|
|
- 'apps/**'
|
|
- 'packages/**'
|
|
- 'scripts/**'
|
|
- 'package.json'
|
|
- 'pnpm-workspace.yaml'
|
|
- 'tsconfig.base.json'
|
|
- '.github/workflows/ci-ts.yml'
|
|
pull_request:
|
|
branches: [main]
|
|
paths:
|
|
- 'services/classes/**'
|
|
- 'apps/**'
|
|
- 'packages/**'
|
|
- 'scripts/**'
|
|
- 'package.json'
|
|
- 'pnpm-workspace.yaml'
|
|
- 'tsconfig.base.json'
|
|
- '.github/workflows/ci-ts.yml'
|
|
|
|
jobs:
|
|
quality:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 9
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'pnpm'
|
|
- name: Install
|
|
run: pnpm install --frozen-lockfile
|
|
- name: Lint
|
|
run: pnpm -r run lint
|
|
continue-on-error: true # P1: ESLint 9 flat config 迁移未完成
|
|
- name: Typecheck
|
|
run: pnpm -r run typecheck
|
|
- name: Test
|
|
run: pnpm -r run test
|
|
continue-on-error: true # P1: 部分服务无 test 脚本
|
|
- name: Build
|
|
run: pnpm -r run build
|
|
|
|
arch-scan:
|
|
runs-on: ubuntu-latest
|
|
needs: quality
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 9
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'pnpm'
|
|
- name: Install
|
|
run: pnpm install --frozen-lockfile
|
|
- name: arch:scan
|
|
run: pnpm run arch:scan
|
|
- name: Verify arch.db committed
|
|
run: |
|
|
if git diff --quiet -- scripts/arch-scan/arch.db; then
|
|
echo "arch.db up to date"
|
|
else
|
|
echo "::warning::arch.db 未同步,请运行 pnpm run arch:scan 并提交"
|
|
fi
|
|
|
|
docker-build:
|
|
runs-on: ubuntu-latest
|
|
needs: quality
|
|
strategy:
|
|
matrix:
|
|
service:
|
|
- { name: classes, dockerfile: services/classes/Dockerfile, context: . }
|
|
- { name: teacher-portal, dockerfile: apps/teacher-portal/Dockerfile, context: . }
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-buildx-action@v3
|
|
- name: Build ${{ matrix.service.name }}
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ${{ matrix.service.context }}
|
|
file: ${{ matrix.service.dockerfile }}
|
|
push: false
|
|
tags: edu/${{ matrix.service.name }}:ci
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|