NC

Naijacloud

Docs

DashboardStart free

Deploy

/

Preview deploys

Preview deploys

With previews enabled, opening a pull request builds a complete environment on its own URL, forked database included, so a change can be reviewed running before it merges.

4 min read

What a preview gives you

When a pull request is opened against the service's connected branch, Naijacloud builds the branch and publishes it on a URL of its own. Reviewers open the link and use the change instead of reading a diff and imagining it.

The previews tab listing open pull requests, each with a preview URL and a forked database
Each open pull request gets its own URL and its own database copy.

Each preview is a full environment: its own container, its own variables, and, where the service has a database attached, its own forked copy of that database.

Why the database is forked

A preview that shares production data is not safe to review: a migration in the branch would run against real rows, and a test order would land in real reporting.

Forking gives the preview a copy to work against, so you can run migrations, insert fixtures, and delete things freely. The copy is discarded with the preview.

!

A fork is a copy taken when the preview is created. It does not receive later writes from the source database, and its own writes never flow back.

Enabling previews

Previews are toggled per service, from its Settings tab.

Service settings with a deployment previews toggle turned on

With the toggle on, previews are created for pull requests from that point onwards. Existing open pull requests get a preview on their next push.

Lifecycle

EventWhat happens
Pull request openedPreview is built and published on its own URL
New commit pushedPreview rebuilds at that commit
Pull request mergedPreview and its database copy are removed
Pull request closedPreview and its database copy are removed

Because previews are torn down automatically, they do not accumulate cost after a branch is done.

Variables in a preview

A preview inherits the variables of the environment its base branch deploys to, with the database connection details replaced by those of its forked copy.

If a value must differ in previews, say a sandbox payment key rather than a live one, set it on the environment the previews inherit from. The live credentials are then never present in a preview at all.

i

Preview URLs are unlisted but publicly reachable, so anyone with the link can open one. Keep that in mind for a change that exposes something not yet announced.

Next steps