The DeployHQ CLI lets you configure automated deployment triggers, scheduled deployments, deployment checks, notification integrations, and network agents.

## Automatic Deployments

Automatic deployments trigger a deployment whenever changes are pushed to your repository.

### Listing Auto-Deploy Configuration

```bash
dhq auto-deploys list -p my-app
```

### Enabling Auto-Deploy for a Server

```bash
dhq auto-deploys enable -p my-app --server production
```

### Disabling Auto-Deploy

```bash
dhq auto-deploys enable -p my-app --server production --disable
```

## Scheduled Deployments

Scheduled deployments run on a recurring schedule (e.g., deploy to staging every night).

### Listing Scheduled Deployments

```bash
dhq scheduled-deploys list -p my-app
```

### Viewing a Scheduled Deployment

```bash
dhq scheduled-deploys show <id> -p my-app
```

### Creating a Scheduled Deployment

```bash
dhq scheduled-deploys create -p my-app \
  --server staging \
  --frequency daily
```

### Deleting a Scheduled Deployment

```bash
dhq scheduled-deploys delete <id> -p my-app
```

## Deployment Checks

Deployment checks gate a deployment at one of two stages:

- `pre_build` -- runs before the build, on the build server
- `post_deploy` -- runs after files have been uploaded to your servers

The CLI creates three types of check:

- `ssh` -- runs a command over SSH on selected servers
- `http` -- sends an HTTP request and validates the response
- `vulnerability_scan` -- runs a security scanner against your source (chosen with `--scanner`); `pre_build` only. See [Vulnerability scan checks](https://www.deployhq.com/support/deployments/deployment-checks/vulnerability-scan-checks) for the supported scanners, severity thresholds, and findings.

DeployHQ also supports post-deploy `error_monitoring` checks that watch a linked error-tracking integration after a deployment. For the full list of check types and options, see [Deployment checks](https://www.deployhq.com/support/deployments/deployment-checks).

### Listing Deployment Checks

```bash
dhq deployment-checks list -p my-app
```

### Viewing a Deployment Check

```bash
dhq deployment-checks show <id> -p my-app
```

### Creating a Deployment Check

An SSH check that runs after a deploy:

```bash
dhq deployment-checks create -p my-app \
  --name "Smoke test" \
  --stage post_deploy \
  --check-type ssh \
  --command "curl -sf http://localhost/health" \
  --servers production
```

An HTTP check that verifies the site responds after deploying:

```bash
dhq deployment-checks create -p my-app \
  --name "Homepage 200" \
  --stage post_deploy \
  --check-type http \
  --http-url "https://example.com" \
  --http-expected-status 200
```

A vulnerability scan that runs before the build:

```bash
dhq deployment-checks create -p my-app \
  --name "Dependency scan" \
  --stage pre_build \
  --check-type vulnerability_scan \
  --scanner trivy \
  --severity-threshold high
```

### Updating and Deleting

```bash
dhq deployment-checks update <id> -p my-app --enabled=false
dhq deployment-checks delete <id> -p my-app
```

## Integrations

Integrations send notifications about deployments to external services (e.g., Slack, email, webhooks).

### Listing Integrations

```bash
dhq integrations list -p my-app
```

### Viewing an Integration

```bash
dhq integrations show <id> -p my-app
```

### Creating an Integration

```bash
dhq integrations create -p my-app \
  --type slack \
  --settings '{"webhook_url":"https://hooks.slack.com/services/..."}'
```

### Updating an Integration

```bash
dhq integrations update <id> -p my-app \
  --settings '{"webhook_url":"https://hooks.slack.com/services/new-url"}'
```

### Deleting an Integration

```bash
dhq integrations delete <id> -p my-app
```

## Network Agents

Network agents allow DeployHQ to deploy to servers behind firewalls. The agent runs on a server inside your network and creates an outbound connection to DeployHQ.

### Listing Agents

```bash
dhq agents list
```

### Creating an Agent

```bash
dhq agents create --name "Office Network" --zone eu
```

### Updating an Agent

```bash
dhq agents update <id> --name "New Office Network"
```

### Revoking Agent Credentials

If an agent's credentials are compromised, revoke them:

```bash
dhq agents revoke <id>
```

After revoking, you will need to reconfigure the agent with new credentials.

### Deleting an Agent

```bash
dhq agents delete <id>
```
