Preview deployments build each open pull request (or merge request) as a separate copy of your application with its own URL. Enable Preview deployments in the application’s advanced settings; OnePloy then deploys a preview when a pull request opens, updates it on every push and deletes it when the pull request closes.
What do I need?
- An application created from Git Repository (with GitHub App) or Git Repository (with GitLab App). Previews rely on the pull request events those apps send. See Git sources.
- A domain for the application, so preview URLs can be derived from it.
How do I turn on preview deployments?
- Open the application and go to Advanced.
- Set Preview deployments to enabled.
- Choose PR deployment access. With Repository members only, only owners, members and collaborators of the repository can trigger previews. Public access lets anyone who opens a pull request trigger one.
- Open a pull request. A preview deployment starts automatically.
How are preview URLs built?
Each preview gets a URL from the URL template on the Preview deployments page. The default is:
{{pr_id}}.{{domain}}
For pull request 42 on an application served at app.example.com, the preview is served at 42.app.example.com. Create a wildcard DNS record (*.app.example.com) pointing at the server so every preview resolves. You can also edit the domain of an individual preview.
Can I deploy a preview manually?
Yes. On the Preview deployments page you can load open pull requests from GitHub and choose Deploy preview for any of them. You can also deploy a preview from a Docker image tag by giving it a preview ID.
Do previews use different variables?
Yes. Variables in the Preview deployments set apply only to previews, so you can point them at a test database or sandbox API keys. See Environment variables.
Do previews share storage with production?
Persistent volumes can get an isolated -pr-N suffix per preview, so a preview never writes into production data. See Persistent storage.
How do I remove a preview?
Closing or merging the pull request deletes its preview. You can also remove one from the Preview deployments page, or through the API:
curl -X DELETE \
-H "Authorization: Bearer $API_TOKEN" \
https://app.oneploy.dev/api/v1/applications/APP_UUID/previews/42