Deplo

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.

ArgumentTypeDescription
appIdID!
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.

ArgumentTypeDescription
appIdID!
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.

ArgumentTypeDescription
appIdID!
inputAppPreviewSettingsInput!
input.autoDeployBooleanRebuild a preview when its pull request gets a new commit.
input.baseDomainStringe.g. preview.example.com, with a wildcard DNS record pointing here. Empty clears it back to the zero-configuration nip.io default.
input.buildDraftsBooleanBuild a pull request that is still a draft.
input.commentBooleanPost the preview URL as a comment on the pull request.
input.enabledBoolean
input.forkPolicyStringdeny | approve | allow.
input.httpsBooleanServe previews over HTTPS. Needs a preview domain.
input.maxActiveInt
input.portIntContainer port. Empty => the app's build port.
input.requiredLabelsStringNewline-separated labels a pull request must carry. Empty => no filter.
input.serverIdStringWhere previews run. Empty => the app's own server.
input.ttlDaysInt
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.

ArgumentTypeDescription
appIdID!
prNumberInt!
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.

ArgumentTypeDescription
idID!
mutation {
  approvePreview(id: "prv_9f1c2ab7d3e4f5a6") {
    id
    prNumber
    status
    url
  }
}

redeployPreview

Needs manage_previews. Returns AppPreview.

Rebuild an existing preview at its current head.

ArgumentTypeDescription
idID!
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.

ArgumentTypeDescription
idID!
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).

ArgumentTypeDescription
appIdID!
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.

ArgumentTypeDescription
appIdID!
keyString!
secretBoolean
valueString!
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.

ArgumentTypeDescription
appIdID!
keyString!
mutation {
  deletePreviewEnvVar(appId: "prj_9f1c2ab7d3e4f5a6", key: "DATABASE_URL")
}

See also

Did this page help you?

On this page