Pull request previews

Beta

Every open pull request gets its own running copy of the app, at its own URL.

Beta

This feature is currently beta/experimental and subject to change. It is not recommended for production. Try it out and share your feedback on our GitHub.

Reviewers click a link instead of checking out a branch. Each pull request opened against the app's branch gets a separate stack, deplo-<slug>__pr-<n>, with its own containers, volumes and files, removed when the pull request closes.

  • The URL never changes for the same pull request, so the link posted on it survives a rebuild.
  • A preview inherits the app's variables, except a fork's. See the two rules about forks.
  • An app running the Compose file in its repository previews the pull request's own version of that file.
  • A preview is not an app and not an environment. It has no domains of its own, and no console, backups or monitoring.
HostnameTLS
No preview domain, the defaultblog-pr-42-3f9a1c-cb00710a.deplo.sitePlain HTTP
A preview domain set, HTTPS onblog-pr-42.preview.example.comA Let's Encrypt certificate per preview

Each preview also gets DEPLO_ENVIRONMENT=preview, DEPLO_PREVIEW=1, DEPLO_PREVIEW_HOST, DEPLO_PREVIEW_URL, DEPLO_GIT_BRANCH and DEPLO_PR_NUMBER.

Turn it on

Only an app deploying from a connected GitHub App can have previews. For other sources the settings are visible but disabled, with the reason shown.

Open pull request settings

Open the app, then Settings -> Pull requests.

Turn on previews

Turn on Deploy pull requests. This saves immediately.

Use the tab

A Pull requests tab appears on the app.

Settings

SettingDefaultWhat it does
Preview domainnoneA base like preview.example.com, with one wildcard DNS record pointing at the server. Unlocks HTTPS
HTTPSoffA certificate per preview. Locked until a preview domain is set
Rebuild on every commitonOff, a new commit is only recorded, and Redeploy preview builds the latest one
Live previews3How many run at once, 1 to 50
Portthe app'sThe port a preview answers on, and PORT inside it
Only pull requests labellednoneOne label per line. Only pull requests carrying one get a preview; removing the label destroys it
Build draftsoffOff, a draft waits until it is marked ready for review
Comment on the pull requestonPosts the URL as one comment, kept up to date. Needs Pull requests: write on your GitHub App
Destroy after3 daysDays without activity before a preview is destroyed, 1 to 365. A new commit resets the clock
Fork pull requestsWait for approvalOr Ignore them, or Build them automatically
ServerSame as the appWhere previews run, often a cheaper machine. Changing it stops the running previews; Redeploy preview starts each one there

Only pull requests labelled and every row after it are under Advanced.

For an app on a cluster, Server reads Same as the app (eu) and the cluster picks a server for each preview. See Pull request previews on a cluster.

Day to day

The Pull requests tab lists every preview, with Redeploy preview, Destroy preview and Open pull request on each row. New preview deploys one on demand, drafts included.

Preview deployments in the history, each on its own pull request URL
  • A title edit updates the row without building.
  • Changing the target branch of the pull request removes its preview.
  • A closed pull request keeps its row for a week, then disappears.
  • The comment on the pull request shows the current state: Building, Ready, Failed, Stopped, Waiting for approval, Not built or Torn down.

The two rules about forks

  • A fork preview inherits no variables at all. Not the app's own, not a shared one. It gets only its plain preview overrides and the DEPLO_ variables above; a secret override is dropped, and images are pulled without your team's registry credentials. The code comes from outside your team. An app that needs a database URL to start needs one set as a plain preview override.
  • A fork preview waits for a human, unless Fork pull requests is set to build them automatically. Somebody with manage_previews presses Review and deploy on the row marked Needs approval. Each new commit needs approval again, and takes the running preview down until then.

A fork is refused outright while the app has a Bind of a server folder or a privileged compose setting, or while a compose file kept in Deplo carries variable values inline.

Over the limit

At the Live previews maximum, a new preview stops the one with the oldest activity. The stopped row stays, grey, with the same hostname, and the pull request comment says Stopped. Only Redeploy preview brings it back, never a push.

Limits and gotchas

  • Turning previews off destroys every live preview and its data, after a confirmation.
  • Moving the app to another server stops its previews, unless they have a server of their own. Redeploy brings each one back.
  • A hand-written DATABASE_URL points previews at the production database. Set a preview override first. A connected database variable is production only.
  • A preview domain belongs to one team. Another team cannot claim a parent or a child of it.
  • Previews use real resources. Ten open pull requests are ten running stacks.

If it does not work

  • The Pull requests tab never appears: the app does not deploy from a GitHub App, or the switch is off.
  • Deplo is missing access on GitHub: the GitHub App lacks the pull request permission. Use Update on GitHub on that notice.
  • A fork preview never deploys: it is waiting for approval, forks are ignored, or the app is refused for forks (see above).

See Deploys and builds for more.

Next steps

Did this page help you?

On this page