Files
furkanyigit34 e007cfc398 ci: tertemiz auto-deploy workflow ekle (SellerX pattern)
Ne yaptık:
- .github/workflows/deploy.yml: validate (backend pytest + frontend lint/build)
  → build-push GHCR (backend + frontend image) → Coolify webhook
  → verify (Coolify polling + public URL health check) → notify-failure
  (GitHub issue auto-create) zinciri eklendi.
- .github/workflows/ci.yml: eski "Deploy to Coolify" job'u kaldırıldı.
  CI artık sadece test + build doğrulaması yapıyor; deploy ayrı workflow'a alındı.
- Trigger: main branch'e push (workflow_dispatch ile manuel de tetiklenebilir).

Neden yaptık:
- Şu ana kadar Coolify deploy manuel tetikleniyordu (CLAUDE.md "Coolify deploy
  otomatik tetiklenmez" notu). Her push sonrası Coolify panel'inden el ile
  redeploy gerekiyordu.
- SellerX'in deploy-frontend.yml mimarisi — validate → build-push → deploy
  → verify zinciri — battle-tested. Aynı pattern'i trendyol-analiz'e port
  ediyoruz.
- GHCR'a image push: ileride Coolify build yerine "image: ghcr.io/..." pull
  yapabilsin diye. Şu an compose 'build:' kullansa bile cache + rollback için
  GHCR'da hazır image bulunuyor.
- verify polling + public URL health check: deploy başarısız olursa GitHub
  Actions otomatik fail eder ve notify-failure GitHub Issue açar.

Gerekli GitHub Secrets (Settings → Secrets and variables → Actions):
- COOLIFY_BASE_URL
- COOLIFY_API_TOKEN
- COOLIFY_TRENDYOL_UUID = x4c08gc84kcw4oow0ggg44cg
2026-04-25 15:35:15 +03:00

206 lines
5.9 KiB
YAML

name: Trendyol Analiz CI/CD
on:
push:
branches: [main, master, develop]
pull_request:
branches: [main, master]
env:
PYTHON_VERSION: '3.13'
NODE_VERSION: '20'
jobs:
# Backend Build & Test (FastAPI)
backend:
name: Backend (FastAPI)
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_DB: trendyol_db
POSTGRES_USER: postgres
POSTGRES_PASSWORD: testpassword
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
defaults:
run:
working-directory: backend
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: backend/requirements.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-test.txt || true
- name: Lint with flake8 (optional)
run: |
pip install flake8 || true
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics || true
- name: Run tests
run: |
pip install pytest pytest-asyncio httpx || true
pytest || echo "No tests found or tests skipped"
env:
DATABASE_URL: postgresql://postgres:testpassword@localhost:5432/trendyol_db
# Frontend Build & Test (React + Vite)
frontend:
name: Frontend (React + Vite)
runs-on: ubuntu-latest
defaults:
run:
working-directory: admin-panel
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: admin-panel/package-lock.json
- name: Install dependencies
run: npm ci
- name: Lint check
run: npm run lint || true
- name: Build
run: npm run build
env:
VITE_API_URL: http://localhost:8001
- name: Upload frontend artifact
uses: actions/upload-artifact@v4
with:
name: frontend-dist
path: admin-panel/dist
retention-days: 1
# Docker Build Test
docker-build:
name: Docker Build Test
runs-on: ubuntu-latest
needs: [backend, frontend]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Backend Docker image
uses: docker/build-push-action@v5
with:
context: .
file: backend/Dockerfile
push: false
tags: trendyol-backend:test
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build Frontend Docker image
uses: docker/build-push-action@v5
with:
context: ./admin-panel
push: false
tags: trendyol-frontend:test
build-args: |
VITE_API_URL=http://localhost:8010
cache-from: type=gha
cache-to: type=gha,mode=max
# Full Integration Test (Docker Compose)
integration:
name: Integration Test
runs-on: ubuntu-latest
needs: [backend, frontend]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create test docker-compose
run: |
cat > docker-compose.test.yml << 'EOF'
name: trendyol-test
services:
postgres:
image: postgres:15-alpine
environment:
POSTGRES_DB: trendyol_db
POSTGRES_USER: postgres
POSTGRES_PASSWORD: testpassword
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 10
backend:
build:
context: .
dockerfile: backend/Dockerfile
environment:
PYTHONUNBUFFERED: 1
DATABASE_URL: postgresql://postgres:testpassword@postgres:5432/trendyol_db
CATEGORIES_DIR: /data/categories
REPORTS_DIR: /data/reports
FRONTEND_URL: http://localhost:3010
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8001/health"]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
EOF
- name: Start services
run: docker compose -f docker-compose.test.yml up -d --build
- name: Wait for backend
run: |
echo "Waiting for backend to be healthy..."
timeout 120 bash -c 'until docker compose -f docker-compose.test.yml ps backend | grep -q "healthy"; do sleep 5; done' || \
(docker compose -f docker-compose.test.yml logs && exit 1)
- name: Test backend health
run: |
docker compose -f docker-compose.test.yml exec -T backend curl -f http://localhost:8001/health || \
(docker compose -f docker-compose.test.yml logs backend && exit 1)
- name: Cleanup
if: always()
run: docker compose -f docker-compose.test.yml down -v
# Deploy is handled by .github/workflows/deploy.yml (auto-trigger on main push)