DigitalOcean Provider

Deploy preview environments to DigitalOcean Droplets via SSH.

How it works

Prerequisites

  1. A DigitalOcean account.
  2. A personal access token with read/write scope.
  3. An SSH key registered in DigitalOcean (used for Droplet access).

Step 1 — Create a DigitalOcean personal access token

  1. Go to API → Tokens → Generate New Token.
  2. Enable both Read and Write scopes.
  3. Store the token as DIGITALOCEAN_TOKEN in Previewops secrets.

Step 2 — Register an SSH key in DigitalOcean

If you already have an SSH key pair:

  1. Go to Settings → Security → SSH Keys → Add SSH Key.
  2. Paste the public key.
  3. Note the Key ID (numeric) or fingerprint shown after adding it (or find either with doctl compute ssh-key list).

If you need a new key pair:

ssh-keygen -t ed25519 -C "previewops" -f ~/.ssh/previewops
# Upload ~/.ssh/previewops.pub to DigitalOcean (step above)
# Store the private key content as DO_SSH_PRIVATE_KEY in previewops secrets
cat ~/.ssh/previewops

Step 3 — Store secrets in Previewops

Secret Value
DIGITALOCEAN_TOKEN Personal access token from step 1
DO_SSH_PRIVATE_KEY PEM-encoded private key from step 2

Step 4 — Configure the repo

provider: digitalocean
providerConfig:
  sshKeyId: "12345678"   # required — numeric Key ID or fingerprint from step 2
                         # find yours with: doctl compute ssh-key list
  region: nyc3           # optional (default: nyc3); run `doctl compute region list` for options
  size: s-1vcpu-1gb      # optional (default: s-1vcpu-1gb); run `doctl compute size list` for options

Complete example with all options:

# .previewops.yaml
provider: digitalocean
providerConfig:
  sshKeyId: "12345678"      # DigitalOcean SSH key ID or fingerprint (required)
  region: nyc3              # Droplet region (default: nyc3)
  size: s-1vcpu-1gb         # Droplet size (default: s-1vcpu-1gb)

# Common options — all optional
concurrency: 3              # max simultaneous active previews per repo
ttlHours: 24                # auto-delete after N hours (default: 24)
port: 3000                  # optional — auto-detected from your Dockerfile EXPOSE; falls back to 8080
memory: 512Mi               # container memory passed to docker run (default: 512Mi)
cpu: 1                      # CPU shares passed to docker run (default: 1)
dockerfile: Dockerfile      # Dockerfile path relative to repo root (default: Dockerfile)
buildContext: .             # Docker build context (default: .)
env:
  NODE_ENV: preview         # inject env vars into the preview container

Step 5 — Verify

Comment /validate-previewops on any open PR. The bot will call GET /v2/account and report the account email and status.

Notes

Troubleshooting

Error Fix
DIGITALOCEAN_TOKEN environment variable is required Set the token in secrets
digitalocean providerConfig.sshKeyId is required Add sshKeyId to providerConfig
SSH connection refused Droplet hasn't finished cloud-init; the provider waits 3 min automatically
docker: command not found cloud-init failed — check Droplet console logs in the DO dashboard