Deployments

Deploy your sites and manage deployment history.

init

Create a zerodeploy.json config file to avoid repetitive CLI flags.

zerodeploy init [options]

OptionDescription
--site <site>Site slug
--dir <directory>Build output directory
--build <command>Build command
--ignore <patterns>Glob patterns to ignore during deploy
--forceOverwrite existing config file
bash
# Create config file (auto-detects framework)
zerodeploy init --site my-website

This creates zerodeploy.json:

json
{
  "site": "my-website",
  "dir": "dist",
  "build": "npm run build",
  "ignore": ["*.map", "drafts/"]
}

Now deploy with a single command:

bash
zerodeploy deploy           # deploy only
zerodeploy deploy --build   # build + deploy

Config Options

FieldDescription
siteSite slug
dirBuild output directory
buildBuild command (used with --build flag)
installInstall command (used with --install flag)
ignoreGlob patterns to exclude from deploy (e.g., ["*.map", "drafts/"])

CLI flags always take precedence over config values.

deploy

Deploy a directory to a site.

zerodeploy deploy [site] [options]

OptionDescription
--org <org>Organization for auto-creating new sites
--dir <directory>Directory to deploy (from config, or auto-detected)
--buildRun build command before deploying
--no-buildSkip build step
--build-command <cmd>Override the build command
--installRun install command before building
--appendKeep existing files and add new ones on top
--previewDeploy without setting as current (preview only)
--no-verifySkip deployment verification
--no-auto-rollbackDisable automatic rollback on verification failure
bash
# Deploy (org/site from zerodeploy.json)
zerodeploy deploy

# Deploy specific directory
zerodeploy deploy --dir ./dist

# Build and deploy
zerodeploy deploy --build

# Install, build, and deploy
zerodeploy deploy --install --build

# Append files to existing deployment (keeps old files)
zerodeploy deploy --append

# Deploy a specific site
zerodeploy deploy my-website --dir ./dist

Deploy Verification

After each deployment, the CLI automatically verifies your site is live by hitting the URL and checking for a 200 response. This catches DNS issues, misconfigurations, and broken deploys before you walk away.

text
Finalizing...
Verifying...

Deployment successful!
URL:     https://my-site.zerodeploy.app (verified)
Preview: https://abc12345-my-site.zerodeploy.app

Use --no-verify to skip verification if needed.

Auto-Rollback on Failure

If verification fails (site returns an error or times out), the CLI automatically rolls back to the previous working deployment. This ensures your site is never left broken.

text
Verifying...

Warning: Could not verify deployment
  Received status 502

Auto-rolling back to previous deployment...
Rolled back to a1b2c3d4

Deployment failed verification and was rolled back.
Failed deployment: e5f6g7h8
Check manually: https://my-site.zerodeploy.app

Use --no-auto-rollback to disable automatic rollback. Auto-rollback is skipped for preview deployments since they don't affect your live site.

Framework Auto-Detection

The CLI automatically detects your framework and uses the appropriate build command and output directory:

FrameworkDetectionOutput Dir
Vitevite in depsdist/
Next.jsnext in depsout/
Create React Appreact-scripts in depsbuild/
Vue CLI@vue/cli-service in depsdist/
Astroastro in depsdist/
SvelteKit@sveltejs/kit in depsbuild/
Gatsbygatsby in depspublic/

Preview URLs

Every deployment gets two URLs:

Preview Deployments

Deploy without going live immediately. Useful for client review or staging before promoting to production.

Deploy as Preview

Use the --preview flag to deploy without setting as the current (live) deployment:

bash
zerodeploy deploy --preview

Output:

text
Preview deployment created!
Preview: https://abc12345-mysite.zerodeploy.app

To make this deployment live, run:
  zerodeploy deploy promote abc12345

Promote to Production

After reviewing the preview, promote it to production:

zerodeploy deploy promote <deploymentId>

bash
# Promote using short ID (first 8 chars)
zerodeploy deploy promote abc12345

# Or use full deployment ID
zerodeploy deploy promote 019b1234-5678-90ab-cdef-1234567890ab

The deployment instantly becomes the live version at your production URL.

Preview Workflow Example

bash
# 1. Deploy as preview
zerodeploy deploy --preview
# → Preview: https://abc12345-mysite.zerodeploy.app

# 2. Share preview URL with client for review
# 3. Client approves...

# 4. Promote to production
zerodeploy deploy promote abc12345
# → Now live at https://mysite.zerodeploy.app

deploy promote

Promote a preview deployment to production. When no ID is given, promotes the latest preview deployment.

zerodeploy deploy promote [deploymentId] [options]

ArgumentDescription
deploymentIdDeployment ID (defaults to latest preview deployment)
OptionDescription
--site <site>Site slug (defaults to config/env)
--jsonOutput as JSON for scripting
bash
# Promote the latest preview (uses config for site)
zerodeploy deploy promote

# Promote a specific deployment
zerodeploy deploy promote abc12345

The deployment instantly becomes the live version at your production URL. See Preview Deployments for the full workflow.

GitHub Actions

Set up automated deployments with GitHub Actions.

CI/CD Options

Git metadata is automatically detected in CI environments. The CLI recognizes GitHub Actions, CircleCI, GitLab CI, Bitbucket Pipelines, Azure Pipelines, Travis CI, and Jenkins. You can override auto-detected values using these flags:

OptionDescription
--pr <number>PR number (auto-detected in CI)
--pr-title <title>PR title (auto-detected in some CI)
--commit <sha>Commit SHA (auto-detected in CI)
--commit-message <msg>Commit message (auto-detected in some CI)
--branch <branch>Branch name (auto-detected in CI)
--github-outputOutput deployment info in GitHub Actions format

Minimal Workflow

yaml
name: Deploy
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci && npm run build
      - name: Deploy
        env:
          ZERODEPLOY_TOKEN: ${{ secrets.ZERODEPLOY_TOKEN }}
        run: npx @zerodeploy/cli deploy --dir dist

PR Preview Workflow

Git metadata (PR number, commit SHA, branch) is auto-detected from the GitHub Actions environment:

yaml
- name: Deploy PR Preview
  if: github.event_name == 'pull_request'
  env:
    ZERODEPLOY_TOKEN: ${{ secrets.ZERODEPLOY_TOKEN }}
  run: npx @zerodeploy/cli deploy --dir dist

You can override auto-detected values if needed:

yaml
- name: Deploy PR Preview
  env:
    ZERODEPLOY_TOKEN: ${{ secrets.ZERODEPLOY_TOKEN }}
  run: |
    npx @zerodeploy/cli deploy --dir dist \
      --pr ${{ github.event.pull_request.number }} \
      --commit ${{ github.sha }} \
      --branch ${{ github.head_ref }}

deployments list

List deployment history for a site.

zerodeploy deployments list [site] [options]

OptionDescription
--jsonOutput as JSON for scripting
bash
zerodeploy deployments list

Example output:

text
Deployments:

  019b1234  ready       12/14/2025, 9:00:00 PM (current)
            [abc1234] (main) - Fix header styling

  019b1230  ready       12/14/2025, 8:30:00 PM
            [def5678] (main) - Add new feature

  019b1220  ready       12/14/2025, 8:00:00 PM

deployments show

View detailed information about a deployment. When no ID is given, shows the current production deployment.

zerodeploy deployments show [id] [options]

ArgumentDescription
idDeployment ID (defaults to current deployment)
OptionDescription
--site <site>Site slug (defaults to config/env)
--jsonOutput as JSON for scripting
bash
zerodeploy deployments show 019b1234

Example output:

text
Deployment Details
==================================================

ID:        019b1234-5678-9abc-def0-1234567890ab
Status:    ✅ Ready
Created:   12/14/2025, 9:00:00 PM

URLs
--------------------------------------------------
Production:  https://my-site.zerodeploy.app
Preview:     https://019b1234-my-site.zerodeploy.app

Git Info
--------------------------------------------------
Branch:    main
Commit:    abc1234567890
Message:   Fix header styling

Files
--------------------------------------------------
Count:     156 files
Size:      2.4 MB

deployments logs

View structured logs from the deployment finalize process. Useful for debugging failed or slow deployments. When no ID is given, shows logs for the latest deployment.

zerodeploy deployments logs [id] [options]

ArgumentDescription
idDeployment ID (defaults to latest deployment)
OptionDescription
--site <site>Site slug (defaults to config/env)
--jsonOutput as JSON for scripting
bash
zerodeploy deployments logs 019b1234

Logs include timing, phase, and metadata for each step of the finalize process (extraction, validation, upload, cache invalidation).

rollback

Roll back to a previous deployment.

zerodeploy rollback [site] [options]

OptionDescription
--to <deploymentId>Deployment ID to rollback to (defaults to previous deployment)
bash
# Rollback to previous deployment (site from config/env)
zerodeploy rollback

# Rollback to specific deployment
zerodeploy rollback --to 019b1230

The specified deployment becomes the current live deployment instantly. You can use the full deployment ID or just the first 8 characters.

SPA Support

ZeroDeploy automatically handles SPA (Single Page Application) routing:

Caching

Cache headers are set automatically based on file type:

File TypeCache Strategy
HTML filesmax-age=0, must-revalidate
Hashed assets (e.g., main.abc123.js)max-age=31536000, immutable
Other assetsmax-age=3600, stale-while-revalidate