ci: proper CI + self-hosted runner deploy workflow

ci.yml — runs on GitHub's servers (free):
- API: dotnet build + test with Postgres/Redis service containers
- Dashboard + Finder: TypeScript typecheck (tsc --noEmit)

deploy.yml — runs on YOUR Linux server (self-hosted runner):
- Triggers on every push to main
- docker compose build --parallel (BuildKit cache)
- Rolling restart with --no-deps --remove-orphans
- Health-check poll: waits up to 2min for API healthy
- Auto-prunes old images after successful deploy

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-05-27 21:45:39 +03:30
parent a85890f30a
commit ac8a9442e3
2 changed files with 97 additions and 43 deletions
+33 -30
View File
@@ -2,31 +2,46 @@ name: CI
on:
push:
branches: [main, master, develop]
branches: [main]
pull_request:
branches: [main, master, develop]
branches: [main]
jobs:
# ── API: build + test ──────────────────────────────────────────────────────
api:
name: API (dotnet build + test)
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_DB: meezi_test
POSTGRES_USER: meezi
POSTGRES_PASSWORD: meezi_test_pass
ports: ["5432:5432"]
options: --health-cmd pg_isready --health-interval 5s --health-timeout 5s --health-retries 10
redis:
image: redis:7-alpine
ports:
- 6379:6379
ports: ["6379:6379"]
options: --health-cmd "redis-cli ping" --health-interval 5s --health-timeout 3s --health-retries 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: "10.0.x"
- name: Restore
run: dotnet restore src/Meezi.API/Meezi.API.csproj
run: dotnet restore
- name: Build
run: dotnet build src/Meezi.API/Meezi.API.csproj --no-restore -c Release
run: dotnet build --no-restore -c Release
- name: Test
run: dotnet test tests/Meezi.API.Tests/Meezi.API.Tests.csproj -c Release
run: dotnet test --no-build -c Release --logger "console;verbosity=minimal"
env:
ConnectionStrings__DefaultConnection: Host=localhost;Port=5432;Database=meezi_test;Username=meezi;Password=meezi_test_pass
ConnectionStrings__Redis: localhost:6379
web:
# ── Dashboard: typecheck ───────────────────────────────────────────────────
dashboard:
name: Dashboard (Next.js typecheck)
runs-on: ubuntu-latest
defaults:
run:
@@ -38,38 +53,26 @@ jobs:
node-version: "20"
cache: npm
cache-dependency-path: web/dashboard/package-lock.json
- run: npm ci
- run: npm run build
- run: npm install --legacy-peer-deps --ignore-scripts
- run: npx tsc --noEmit
env:
NEXT_PUBLIC_API_URL: http://localhost:5080
e2e:
# ── Finder: typecheck ──────────────────────────────────────────────────────
finder:
name: Finder (Next.js typecheck)
runs-on: ubuntu-latest
continue-on-error: true
defaults:
run:
working-directory: web/dashboard
working-directory: web/finder
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: npm
cache-dependency-path: web/dashboard/package-lock.json
- run: npm ci
- run: npx playwright install chromium --with-deps
- name: E2E (API-only smoke; set PLAYWRIGHT_API_URL when API service available)
run: npm run test:e2e -- e2e/api-health.spec.ts
cache-dependency-path: web/finder/package-lock.json
- run: npm install --legacy-peer-deps --ignore-scripts
- run: npx tsc --noEmit
env:
PLAYWRIGHT_API_URL: http://localhost:5080
flutter:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
- run: flutter analyze mobile/meezi_app
- run: flutter analyze mobile/meezi_pos
NEXT_PUBLIC_API_URL: http://localhost:5080