DigitalOcean Provider
Deploy preview environments to DigitalOcean Droplets via SSH.
How it works
- Build: SSHs into a fresh Droplet, clones the repo, and runs
docker build. Docker is installed automatically via cloud-init on first boot. - Deploy: runs the built Docker image in a container on the same Droplet. Each PR gets its own Droplet.
- Delete: destroys the Droplet.
- List: lists all Droplets tagged
preview-repo-{owner}-{repo}.
Prerequisites
- A DigitalOcean account.
- A personal access token with read/write scope.
- An SSH key registered in DigitalOcean (used for Droplet access).
Step 1 — Create a DigitalOcean personal access token
- Go to API → Tokens → Generate New Token.
- Enable both Read and Write scopes.
- Store the token as
DIGITALOCEAN_TOKENin Previewops secrets.
Step 2 — Register an SSH key in DigitalOcean
If you already have an SSH key pair:
- Go to Settings → Security → SSH Keys → Add SSH Key.
- Paste the public key.
- 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
region: nyc3 # optional (default: nyc3)
# see: doctl compute region list
size: s-1vcpu-1gb # optional (default: s-1vcpu-1gb)
# see: doctl compute size list
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
- Droplets are provisioned on-demand for each PR and destroyed on delete/close.
- First deploy takes ~3 minutes (Droplet boot + Docker/git installation via cloud-init).
- Subsequent deploys to the same PR reuse the existing Droplet and are faster (~30s).
- The preview URL is
http://{droplet-ip}. For HTTPS, place a load balancer or Caddy reverse proxy in front.
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 |