Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

🚁 Create a staging environment deployment for pull requests #1070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
kasperpeulen wants to merge 1 commit into epicweb-dev:main
base: main
Choose a base branch
Loading
from kasperpeulen:kasper/staging-app-per-pr

Conversation

@kasperpeulen
Copy link
Contributor

@kasperpeulen kasperpeulen commented Dec 24, 2025
edited
Loading

Closes #1067

Summary

Implements per-PR staging environments using Fly.io's API, resolving the staging bottleneck issue discussed in #1067.

Problem

Previously, the Epic Stack used a single shared staging environment (app-name-staging) which created several issues:

  • Staging bottleneck: Only one PR could be properly tested at a time
  • Unclear test failures: Hard to determine if QA failures were from your PR or conflicting changes
  • Serial workflow: Teams couldn't perform parallel quality assurance
  • Extra setup: Required creating and maintaining a separate staging app during initial deployment

Solution

Each pull request now gets its own isolated staging environment with:

  • Unique Fly app per PR (e.g., app-name-pr-123)
  • Automatic provisioning of database, secrets, object storage, and Consul
  • Pre-seeded test data for immediate testing
  • Automatic cleanup when PRs are closed
  • GitHub environment integration with deployment URLs

Changes

CI/CD Pipeline (.github/workflows/deploy.yml):

  • Added deploy-staging job using superfly/fly-pr-review-apps@1.5.0
  • Staging apps use GitHub environment secrets instead of Fly secrets
  • Production deployments only run on pushes to main (removed dev branch)
  • Automatic resource provisioning: SQLite volume, Tigris storage, Consul, and secrets
  • Doesn't run on forks as pull_request from forks has no secret access.

Database Seeding (prisma/seed.staging.sql, other/litefs.yml):

  • Created SQL seed file with test users and notes similar to the seed for local development
  • Automatically seeds staging databases on first deployment

Documentation Updates:

  • docs/deployment.md: Removed staging app setup, added GitHub CLI instructions
  • docs/secrets.md: Updated for GitHub environment secrets
  • docs/email.md, docs/monitoring.md: Updated secret commands for new workflow
  • docs/database.md: Added staging seed documentation

Benefits

  • Parallel QA: Multiple PRs can be tested simultaneously
  • Isolated testing: Each PR has its own environment without conflicts
  • Simplified setup: No separate staging app to configure during initial deployment
  • Automatic cleanup: Resources freed when PRs close
  • Better reviews: Reviewers get direct links to live preview environments

Test Plan

I tested this in my own deployed fork of the epic stack.

See here the production deploy:
https://github.com/kasperpeulen/epic-stack/deployments/production

And here a PR that creates a staging app on the fly:
kasperpeulen#27

Checklist

  • Tests updated
  • Docs updated

Screenshots

image

Copilot AI review requested due to automatic review settings December 24, 2025 11:38
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements per-PR staging environments using Fly.io's PR preview feature, replacing the previous single shared staging environment to enable parallel testing and eliminate staging bottlenecks.

Key Changes:

  • Automated per-PR staging deployments with isolated resources (database, secrets, storage)
  • Removed manual staging app setup from initialization process
  • Migrated staging secrets from Fly.io to GitHub environment secrets

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
.github/workflows/deploy.yml Added deploy-staging job for per-PR environments, removed dev branch deployments, automated resource provisioning
remix.init/index.mjs Removed staging app creation and setup prompts from initialization script
prisma/seed.staging.sql New staging database seed file with test users and notes data
other/litefs.yml Added automatic seeding of staging databases on first deployment
docs/deployment.md Updated deployment instructions removing staging app setup, added GitHub CLI requirement
docs/secrets.md Updated to use GitHub environment secrets for staging instead of Fly secrets
docs/email.md Updated secret management commands for new workflow
docs/monitoring.md Updated Sentry DSN configuration for staging environments
docs/database.md Added documentation for staging database seeding
docs/decisions/047-pr-staging-environments.md Decision record documenting the rationale and impact of the change
prisma/migrations/migration_lock.toml Formatting change (no functional impact)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Amazing @kasperpeulen, thanks for this!

kasperpeulen reacted with heart emoji

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This improves a lot! Thanks!

Why don't we use GitHub for all secrets, even production? I think that would be less confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@kentcdodds kentcdodds kentcdodds left review comments

Copilot code review Copilot Copilot left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /