Files
gh-christianlouis-inboxconv…/.github/workflows/ci.yml
T
copilot-swe-agent[bot] 9ccd0ce881 Add dual-registry Docker deployment (GHCR + private registry)
- Update CI workflow to build separate backend/frontend images via matrix
- Push to both ghcr.io and registry.cklnet.com
- Add private registry login step with secret credentials
- Keep existing metadata-action tags and multi-platform builds
- Update CHANGELOG.md and docs/TODO.md

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
Agent-Logs-Url: https://github.com/christianlouis/pop_puller_to_gmail/sessions/05b6d21a-2397-4039-9c69-46db79ec11de
2026-03-23 22:41:10 +00:00

227 lines
6.6 KiB
YAML

name: CI
on:
push:
branches: [main, develop]
tags:
- 'v*'
pull_request:
branches: [main, develop]
schedule:
- cron: '0 0 * * 0' # Weekly on Sunday (security scans)
workflow_dispatch:
env:
GHCR_REGISTRY: ghcr.io
PRIVATE_REGISTRY: registry.cklnet.com
jobs:
# ── Phase 1: Lint ──────────────────────────────────────────────────────
lint:
name: Lint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install Python linting tools
run: |
python -m pip install --upgrade pip
pip install black ruff mypy
pip install -r backend/requirements.txt
- name: Check code formatting with Black
run: black --check backend/
- name: Lint with Ruff
run: ruff check backend/
- name: Type check with mypy
run: mypy backend/app --ignore-missing-imports
continue-on-error: true
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '20.19.0'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install frontend dependencies
run: npm ci
working-directory: frontend
- name: Lint frontend with ESLint
run: npm run lint
working-directory: frontend
# ── Phase 2: Test ──────────────────────────────────────────────────────
test:
name: Test
needs: lint
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: pop3_forwarder_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: redis:7-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r backend/requirements.txt
pip install pytest pytest-asyncio pytest-cov httpx
- name: Run tests with coverage
env:
DATABASE_URL: postgresql+asyncpg://postgres:postgres@localhost:5432/pop3_forwarder_test
REDIS_URL: redis://localhost:6379/0
SECRET_KEY: test-secret-key-for-ci-cd-at-least-32-chars
ENCRYPTION_KEY: test-encryption-key-for-ci-cd-at-least-32-chars
run: |
cd backend
pytest tests/ -v --cov=app --cov-report=xml --cov-report=term
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
file: ./backend/coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
# ── Phase 3: Security ──────────────────────────────────────────────────
security:
name: Security
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install bandit safety
pip install -r backend/requirements.txt
- name: Run Bandit security scan
run: bandit -r backend/app -ll
continue-on-error: true
- name: Check dependencies for known vulnerabilities
run: safety check --json
continue-on-error: true
# ── Phase 4: Build ─────────────────────────────────────────────────────
build:
name: Build & Push Docker Image
needs: security
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- context: ./backend
image_name: gmail-puller/backend
- context: ./frontend
image_name: gmail-puller/frontend
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.GHCR_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Requires PRIVATE_REGISTRY_USERNAME and PRIVATE_REGISTRY_PASSWORD secrets
- name: Log in to private registry
uses: docker/login-action@v3
with:
registry: ${{ env.PRIVATE_REGISTRY }}
username: ${{ secrets.PRIVATE_REGISTRY_USERNAME }}
password: ${{ secrets.PRIVATE_REGISTRY_PASSWORD }}
- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.GHCR_REGISTRY }}/${{ github.repository_owner }}/${{ matrix.image_name }}
${{ env.PRIVATE_REGISTRY }}/${{ matrix.image_name }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
id: build-push
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64