docs/preview-environment-plan.md
Preview Environment Plan
Preview Environment Plan
Goal
Provide pragmatic per-PR previews with dependency-aware deploys:
portalalways previewedcore-apiandlearning-apipreviewed only when needed- fall back to UAT resources when previews are unnecessary
Keep
- Keep Supabase GitHub integration as the source of truth for preview branch lifecycle.
- Keep Supabase integration responsible for preview branch migrations and baseline seeding.
- Keep
.github/workflows/deploy_preview_env.yamlas the app preview orchestrator. - Keep preview app deploys stateless and environment-driven.
Clean Up
- Remove implicit fallback from preview deploys to staging Supabase credentials.
- Standardize Supabase preview secret names in GitHub workflows:
SUPABASE_CLI_ACCESS_TOKENUAT_SUPABASE_PROJECT_ID
- Keep
apps/supabase/scripts/deploy-preview.shandapps/supabase/scripts/postdeploy-preview.shas no-ops for now, but treat them as legacy paths and avoid building new behavior there.
Seeding Policy
- Seed only the Supabase preview branch, never app previews directly.
- Keep baseline preview seed data in Supabase-managed seed flow (
seed.sql/ integration flow). - Do not run destructive custom seed scripts on every push (
synchronize). - If custom seeding is needed later, run it only on branch creation events (
opened/reopened) and make it idempotent.
Rollout Plan
- Detect changed scopes in
deploy_preview_env:apps/core-api/**apps/learning-api/**apps/supabase/migrations/**orapps/supabase/schemas/**
- Compute deploy chain:
deploy_learning_preview = learning_changed OR supabase_changeddeploy_core_preview = core_changed OR deploy_learning_preview
- Always deploy
portalpreview. - Deploy
learning-apipreview only whendeploy_learning_preview=true. - Deploy
core-apipreview only whendeploy_core_preview=true. - Reuse UAT URLs when preview deploy is skipped.
- Use Supabase preview branch only when learning/supabase-dependent preview chain is active.
- Export Infisical secrets from
stagingfor both services:/learning-api/usesstaging./backend/usesstaging.
- Force internal learning-api service wiring in preview runtime:
API_URL=http://api:8000REDIS_URL=redis://redis:6379/0CELERY_BROKER_URL=redis://redis:6379/0CELERY_RESULT_BACKEND=redis://redis:6379/0
Out of Scope (Current Pass)
- Marketing/email preview fixes.
- Dependency/version mismatch cleanup.
- Custom GitHub Action seeding pipeline.