Skip to content
Latchkey

surge: Deploy Static Sites from CI

surge <path> <domain> publishes a static directory to the given surge.sh (or custom) domain in one command.

Surge is a minimal static host. A single command deploys a folder, which makes it easy to script once you supply credentials via env vars.

What it does

surge uploads the contents of the project path and serves them at the chosen domain. The first positional argument is the directory to publish and the second is the domain. surge token prints a token for non-interactive auth and surge teardown removes a deployment.

Common usage

Terminal
# credentials come from env vars; no prompts
export SURGE_LOGIN=you@example.com SURGE_TOKEN=xxxxxxxx
surge ./dist my-app.surge.sh
# remove a deployment
surge teardown my-app.surge.sh

Options

Arg / commandWhat it does
surge <path> <domain>Publish a directory to a domain
tokenPrint an auth token for CI
teardown <domain>Remove a deployment
SURGE_LOGINAccount email for non-interactive auth
SURGE_TOKENAuth token for non-interactive auth

In CI

Set both SURGE_LOGIN and SURGE_TOKEN (from surge token); with only one set the CLI still drops into an interactive email/password prompt and hangs. Pass the domain explicitly so surge does not prompt for one. Generate the token once and store it as a secret.

Common errors in CI

A job that hangs waiting for "email:" or "password:" means SURGE_LOGIN or SURGE_TOKEN is missing; set both. "Aborted, this domain is already owned by another user" means the surge.sh subdomain is taken; pick another. "project not found" means the path argument points at a directory that does not exist.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →