Blog-
Shared staging vs a preview per PR
Why shared staging keeps breaking, what a preview per pull request fixes, and what should stay shared. A practical split for small teams, no Kubernetes required.
Every team with one shared staging environment knows the message: "Who broke staging?" Someone deployed a half-finished branch. Someone else seeded test data and never cleaned it up. A stakeholder demo gets pushed because nobody can say what state the environment is in.
Nobody did anything unreasonable, and it still breaks. Jose da Cruz calls shared staging a tragedy of the commons: "everyone benefits from using it a little carelessly, but nobody personally pays for the mess they leave behind." Reminders in the team channel don't change that. The setup has to change.
Here is a practical split: what a preview per pull request should take over, and what staging should keep doing on purpose.
Why shared staging keeps breaking
Shared staging turns into a bottleneck when people's deploys, tests and data changes get in each other's way. The usual ways it happens:
- One deploy overwrites another developer's work in progress.
- Shared databases, queues, caches and test accounts mix data from different branches.
- A test fails and nobody can tell which change caused it.
- People wait for their turn. A booking calendar decides who goes next, but everyone still waits.
None of this is a discipline problem. Twelve careful engineers sharing one environment will still collide, because each shortcut is cheap for the person taking it and expensive for the next person in line.
What a preview per PR fixes
A preview is a short-lived environment tied to one change. You open a pull request, it builds, and an HTTPS URL appears on the PR. When the PR closes, the preview is removed.
That takes most of the daily traffic off staging:
- No overwrites. Each branch runs in its own place, so your deploy can't replace someone else's.
- Clear blame. If the preview for a PR is broken, the cause is in that PR.
- No queue for review. Product, QA or a client can open the link on the PR the same day the code exists, instead of waiting for a staging slot. The Kubernetes decision guide covers why that early review matters.
- Automatic cleanup. Previews go away on close, so nothing rots for weeks.
This matters more as pull request volume goes up. When coding tools produce more PRs than a team can review, one shared environment becomes the narrowest point in the pipeline. We wrote about that in AI ships more pull requests. Preview apps decide if they're any good.
One caveat: a preview should isolate more than the URL. If two previews write to the same mutable state, you have moved the collision, not removed it. Know what each preview shares.
What should stay on shared staging
You could stop sharing altogether. For most small teams that is not realistic, and not even desirable. Staging still has jobs that belong in one shared place:
- Integration testing. Checking how merged changes behave together, against the real neighbours.
- Release checks. The last look before production, on an environment that looks like production.
- Things you can't copy cheaply. A shared database snapshot, a third-party sandbox account, a payment provider test mode. These often stay shared.
Give each job its place: in-progress work goes to a preview per PR, and integration and release checks stay on staging, deliberately.
Coordinate what stays shared
Whatever stays shared needs a few simple rules, or the old problems come back in a smaller room:
- List the shared resources. The staging deploy target, the database, vendor sandboxes. Write them down where everyone can see them.
- Use visible locks that expire. For deploys, migrations and destructive tests. A lock with a name and an end time beats a message in a channel.
- Make CI follow the same rules as people. A pipeline that deploys to staging takes and releases the lock like anyone else.
- Release locks when you're done. Expiry is the safety net, not the plan.
- Split a resource that is busy most of the time. If one sandbox is always locked, that is the next thing to isolate.
How to choose
| Situation | Where it goes |
|---|---|
| A branch someone wants reviewed | Preview per PR |
| A PM, QA or client checking a change before merge | Preview per PR |
| Merged changes tested together | Shared staging |
| Final check before a release | Shared staging or preprod |
| A third-party sandbox you can't duplicate | Shared, with a visible lock |
Getting a preview per PR without Kubernetes
The heavy version of this setup copies a whole environment for every PR on a Kubernetes platform. That works if you already run one. If you don't, it means taking on a platform to solve a review problem.
Beforeprod is the lighter path. A GitHub Action in the CI you already run builds the branch, an isolated HTTPS preview comes up, and the URL is written into the pull request. Close the PR and the preview goes away. Go and JavaScript (including Next.js) are supported today. You keep shared staging for the jobs above.
You can try it on the public demos: preview-demo-go and preview-demo-js.
Start small
- Pick one repo that fights over staging most.
- Give every PR in it a preview URL for two weeks.
- Keep staging for integration and release checks only, and add a visible lock for deploys.
If "who broke staging?" gets rarer and reviews start earlier, keep going.
Beforeprod is in early access. If you want preview URLs on your PRs, join the waitlist or email info@beforeprod.com.