Pull request previews
Preview settings, the previews of an app, deploying a pull request, and preview-only variables.
A preview is a short-lived deployment of one pull request, on its own hostname. A pull request from a fork waits for approval; deployPullRequest on it is the approval.
Reading
appPreviews
Needs manage_previews. Returns AppPreviewsView.
Pull request previews for an app, plus why they may not work.
| Argument | Type | Description |
|---|---|---|
appId | ID! |
query {
appPreviews(appId: "prj_9f1c2ab7d3e4f5a6") {
enabled
previews {
id
prNumber
status
url
}
}
}openPullRequests
Needs manage_previews. Returns [GithubPullRequest!].
Open pull requests on the app's repository, for the deploy picker. Needs only pull_requests: read, which every Deplo GitHub App has.
| Argument | Type | Description |
|---|---|---|
appId | ID! |
query {
openPullRequests(appId: "prj_9f1c2ab7d3e4f5a6") {
number
title
headRef
fromFork
}
}Settings
setAppPreviewSettings
Needs manage_previews. Returns Boolean.
Turn pull request previews on or off, and set their options.
| Argument | Type | Description |
|---|---|---|
appId | ID! | |
input | AppPreviewSettingsInput! | |
input.autoDeploy | Boolean | Rebuild a preview when its pull request gets a new commit. |
input.baseDomain | String | e.g. preview.example.com, with a wildcard DNS record pointing here. Empty clears it back to the zero-configuration nip.io default. |
input.buildDrafts | Boolean | Build a pull request that is still a draft. |
input.comment | Boolean | Post the preview URL as a comment on the pull request. |
input.enabled | Boolean | |
input.forkPolicy | String | deny | approve | allow. |
input.https | Boolean | Serve previews over HTTPS. Needs a preview domain. |
input.maxActive | Int | |
input.port | Int | Container port. Empty => the app's build port. |
input.requiredLabels | String | Newline-separated labels a pull request must carry. Empty => no filter. |
input.serverId | String | Where previews run. Empty => the app's own server. |
input.ttlDays | Int |
mutation {
setAppPreviewSettings(
appId: "prj_9f1c2ab7d3e4f5a6"
input: { enabled: true, port: 3000, ttlDays: 7 }
)
}Building and destroying
deployPullRequest
Needs manage_previews. Returns AppPreview.
Build a preview for a specific open pull request. Also approves it when it comes from a fork - clicking this IS the approval.
| Argument | Type | Description |
|---|---|---|
appId | ID! | |
prNumber | Int! |
mutation {
deployPullRequest(appId: "prj_9f1c2ab7d3e4f5a6", prNumber: 42) {
id
prNumber
status
url
}
}approvePreview
Needs manage_previews. Returns AppPreview.
Unblock a fork's pull request and build it. Approval is per pull request, so later commits on it build automatically.
| Argument | Type | Description |
|---|---|---|
id | ID! |
mutation {
approvePreview(id: "prv_9f1c2ab7d3e4f5a6") {
id
prNumber
status
url
}
}redeployPreview
Needs manage_previews. Returns AppPreview.
Rebuild an existing preview at its current head.
| Argument | Type | Description |
|---|---|---|
id | ID! |
mutation {
redeployPreview(id: "prv_9f1c2ab7d3e4f5a6") {
id
prNumber
status
url
}
}destroyPreview
Needs manage_previews. Returns Boolean.
Stop a preview and remove its containers and volumes. The next commit on the pull request builds it again.
| Argument | Type | Description |
|---|---|---|
id | ID! |
mutation {
destroyPreview(id: "prv_9f1c2ab7d3e4f5a6")
}Preview-only variables
An override outranks the app's own value and any shared variable, in previews only.
previewEnvVars
Needs manage_env. Returns [PreviewEnvVar!].
The app's preview-only variable overrides (advanced).
| Argument | Type | Description |
|---|---|---|
appId | ID! |
query {
previewEnvVars(appId: "prj_9f1c2ab7d3e4f5a6") {
key
type
}
}setPreviewEnvVar
Needs manage_env. Returns Boolean.
Set a preview-only override for one variable (advanced). It outranks the app's own value and any shared variable, in previews only.
| Argument | Type | Description |
|---|---|---|
appId | ID! | |
key | String! | |
secret | Boolean | |
value | String! |
mutation {
setPreviewEnvVar(appId: "prj_9f1c2ab7d3e4f5a6", key: "API_URL", value: "https://staging-api.example.com")
}deletePreviewEnvVar
Needs manage_env. Returns Boolean.
Remove a preview-only override.
| Argument | Type | Description |
|---|---|---|
appId | ID! | |
key | String! |
mutation {
deletePreviewEnvVar(appId: "prj_9f1c2ab7d3e4f5a6", key: "DATABASE_URL")
}See also
Did this page help you?