Last updated on 4th April 2026

Deploying with the CLI

The DeployHQ CLI provides several ways to create and manage deployments, from a quick one-liner to detailed deployment management commands.

Quick Deploy

The dhq deploy shortcut is the fastest way to deploy:

# Deploy the default project to the default server
dhq deploy --wait

# Deploy a specific project to a specific server
dhq deploy -p my-app -s production --wait

# Deploy a specific branch
dhq deploy -p my-app -s staging --branch develop --wait

# Deploy a specific commit
dhq deploy -p my-app -s production --revision abc123 --wait

The --wait Flag

By default, dhq deploy queues the deployment and returns immediately. Add --wait to watch the deployment until it completes or fails.

Live TUI Progress

When running in an interactive terminal with --wait, the CLI displays a real-time TUI (text user interface) showing deployment steps as they happen:

Deploying my-app to Production Web...

  Checking access to repository              [done]
  Updating repository                        [done]
  Running build commands                     [in progress]
    npm install                              [done]
    npm run build                            [running]
  Transferring files to server               [pending]

Elapsed: 1m 23s

Fuzzy Server Matching

Server names are fuzzy-matched, so you do not need to type the exact name:

# "prod" matches "Production Web"
dhq deploy -p my-app -s prod --wait

# "fedora" matches "DO - FEDORA"
dhq deploy -p my-app -s fedora --wait

If multiple servers match, the CLI presents a picker in interactive mode, or returns an error in non-interactive mode.

Auto-Server Selection

If your project has only one server, the CLI selects it automatically -- no -s flag needed.

Deployment Management

For more control, use the dhq deployments subcommands.

Listing Deployments

# List recent deployments
dhq deployments list -p my-app

# JSON output with specific fields
dhq deployments list -p my-app --json identifier,status,branch

Viewing Deployment Details

dhq deployments show <deployment-id> -p my-app

Creating a Deployment (Full Control)

dhq deployments create -p my-app \
  --server production \
  --branch main \
  --revision abc123

Watching a Deployment

Monitor an in-progress deployment:

dhq deployments watch <deployment-id> -p my-app

Viewing Deployment Logs

dhq deployments logs <deployment-id> -p my-app

On failure, the CLI automatically shows logs and suggests recovery commands.

Aborting a Deployment

Stop a running deployment:

dhq deployments abort <deployment-id> -p my-app

Rolling Back

Rollback to the previous deployment:

# Shortcut
dhq rollback <deployment-id> -p my-app

# Or via subcommand
dhq deployments rollback <deployment-id> -p my-app

Retrying a Failed Deployment

Retry the last failed deployment:

# Shortcut
dhq retry <deployment-id> -p my-app

# Or via subcommand
dhq deployments retry <deployment-id> -p my-app

Deploying to Server Groups

If your project has server groups configured, you can deploy to all servers in a group simultaneously by specifying the group name with the -s flag:

dhq deploy -p my-app -s "Production Group" --wait

Using the Latest Deployed Commit

Deploy from the last deployed revision to the latest commit:

dhq deploy -p my-app -s production --use-latest --wait

Failure Handling

When a deployment fails with --wait, the CLI automatically:

  1. Shows the deployment logs
  2. Displays suggested next commands (retry, rollback)
  3. Returns a non-zero exit code for CI/CD integration

Example failure output:

Deployment failed.

Suggested actions:
  dhq retry abc123 -p my-app        # Retry this deployment
  dhq rollback abc123 -p my-app     # Rollback to previous version
  dhq deployments logs abc123 -p my-app  # View full logs

Common Workflows

Deploy After a Git Push

git push origin main
dhq deploy -p my-app -s production --wait

Check Status Before Deploying

# View current server revisions
dhq servers list -p my-app

# View recent deployment history
dhq deployments list -p my-app

# Then deploy
dhq deploy -p my-app -s production --wait

Deploy and Open in Browser

dhq deploy -p my-app --wait && dhq open my-app