106 lines
3.1 KiB
YAML
106 lines
3.1 KiB
YAML
name: CI
|
||
|
||
on:
|
||
push:
|
||
branches: [main]
|
||
# 纯文档提交不消耗 2 核 runner;需要状态时用 workflow_dispatch 手动触发。
|
||
paths-ignore:
|
||
- "**.md"
|
||
# PR 不设置 paths-ignore:branch protection 的 required checks 必须始终上报,
|
||
# 否则纯文档 PR 会永远等不到状态检查而无法合并。
|
||
pull_request:
|
||
workflow_dispatch:
|
||
|
||
concurrency:
|
||
group: ci-${{ github.ref }}
|
||
cancel-in-progress: true
|
||
|
||
env:
|
||
NODE_VERSION: "24"
|
||
PNPM_VERSION: "9.15.0"
|
||
|
||
jobs:
|
||
static:
|
||
name: Static checks
|
||
runs-on: ubuntu-latest
|
||
timeout-minutes: 40
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
- uses: pnpm/action-setup@v4
|
||
with:
|
||
version: ${{ env.PNPM_VERSION }}
|
||
- uses: actions/setup-node@v4
|
||
with:
|
||
node-version: ${{ env.NODE_VERSION }}
|
||
cache: pnpm
|
||
- run: pnpm install --frozen-lockfile
|
||
- run: pnpm check
|
||
- run: pnpm test:api-routes
|
||
- run: pnpm validate:templates
|
||
- run: pnpm template:compatibility
|
||
- run: pnpm --filter @personal-brand/api exec tsx --test test/template-preview-matrix.test.ts
|
||
- run: pnpm template:conformance
|
||
- run: pnpm template:doctor
|
||
|
||
build:
|
||
name: Production build
|
||
runs-on: ubuntu-latest
|
||
timeout-minutes: 60
|
||
needs: [static]
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
- uses: pnpm/action-setup@v4
|
||
with:
|
||
version: ${{ env.PNPM_VERSION }}
|
||
- uses: actions/setup-node@v4
|
||
with:
|
||
node-version: ${{ env.NODE_VERSION }}
|
||
cache: pnpm
|
||
- run: pnpm install --frozen-lockfile
|
||
- run: pnpm build
|
||
- run: pnpm build:admin:preview
|
||
- run: pnpm validate:template-release
|
||
|
||
api:
|
||
name: API integration
|
||
runs-on: ubuntu-latest
|
||
timeout-minutes: 45
|
||
needs: [static]
|
||
services:
|
||
postgres:
|
||
image: postgres:16-alpine
|
||
env:
|
||
POSTGRES_USER: postgres
|
||
POSTGRES_PASSWORD: postgres
|
||
POSTGRES_DB: personal_brand
|
||
options: >-
|
||
--health-cmd "pg_isready -U postgres -d personal_brand"
|
||
--health-interval 5s
|
||
--health-timeout 5s
|
||
--health-retries 12
|
||
env:
|
||
DATABASE_URL: postgresql://postgres:postgres@postgres:5432/personal_brand
|
||
DEFAULT_BRAND_ID: 00000000-0000-0000-0000-000000000001
|
||
SESSION_SECRET: ci-integration-session-secret-0123456789abcdef
|
||
SEED_ADMIN_PASSWORD: ci-integration-admin-password
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
- uses: pnpm/action-setup@v4
|
||
with:
|
||
version: ${{ env.PNPM_VERSION }}
|
||
- uses: actions/setup-node@v4
|
||
with:
|
||
node-version: ${{ env.NODE_VERSION }}
|
||
cache: pnpm
|
||
- run: pnpm install --frozen-lockfile
|
||
- name: Prepare API test env
|
||
working-directory: apps/api
|
||
run: |
|
||
cat > .env <<EOF
|
||
DATABASE_URL=$DATABASE_URL
|
||
DEFAULT_BRAND_ID=$DEFAULT_BRAND_ID
|
||
SESSION_SECRET=$SESSION_SECRET
|
||
SEED_ADMIN_PASSWORD=$SEED_ADMIN_PASSWORD
|
||
EOF
|
||
- run: pnpm --filter @personal-brand/api test:integration
|