> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cirron.com/llms.txt
> Use this file to discover all available pages before exploring further.

# deploy

> Deploy models to Cirron environments.

# cirron deploy

Deploy your ML project to Cirron environments (development, staging, production) with automatic build, artifact upload, deployment monitoring, and rollback.

## Usage

```bash theme={null}
cirron deploy [options]
```

## Options

| Option          | Description                                                    | Default        |
| --------------- | -------------------------------------------------------------- | -------------- |
| `--env, -e`     | Target environment (development, staging, production)          | `development`  |
| `--message, -m` | Deployment message                                             | Auto-generated |
| `--no-build`    | Skip build step                                                | `false`        |
| `--force, -f`   | Skip confirmation prompts (required for production unattended) | `false`        |
| `--rollback`    | Rollback to previous successful deployment                     | `false`        |

The command validates `cirron.yaml`, ensures you're authenticated, runs `cirron build` (unless `--no-build`), executes any `beforeDeploy` commands, uploads artifacts, monitors deployment with a 5-minute timeout, and finally runs `afterDeploy` commands. Production deployments require confirmation unless `--force` is passed.

## Rollback

Rolls back to the most recent **other** successful deployment in the target environment.

```bash theme={null}
# Rollback production deployment (prompts for confirmation)
cirron deploy --env production --rollback

# Force rollback without confirmation
cirron deploy --env staging --rollback --force
```

## Examples

```bash theme={null}
# Basic deployments
cirron deploy                                    # development (default)
cirron deploy --env staging
cirron deploy --env production                   # prompts for confirmation
cirron deploy --env production --force           # unattended

# Skip build
cirron deploy --no-build
cirron deploy --env staging --no-build

# Custom messages
cirron deploy --env staging --message "Update model pipeline"
cirron deploy --env production --message "Release v1.2.0" --force

# Rollback
cirron deploy --env production --rollback
cirron deploy --env staging --rollback --force
```

## Configuration

`cirron.yaml` declares environments and optional pre/post-deploy hooks:

```json theme={null}
{
  "name": "my-ml-project",
  "version": "1.0.0",
  "environments": {
    "development": { "url": "https://dev-app.cirron.com", "variables": { "DEBUG": "true" } },
    "staging":     { "url": "https://staging-app.cirron.com" },
    "production":  { "url": "https://app.cirron.com", "variables": { "DEBUG": "false" } }
  },
  "build": {
    "outputDir": "dist/",
    "command": "npm run build"
  },
  "deploy": {
    "beforeDeploy": [
      "echo 'Running pre-deploy checks'",
      "npm run test"
    ],
    "afterDeploy": [
      "echo 'Deployment completed'",
      "curl -X POST https://hooks.slack.com/..."
    ]
  }
}
```

## Monitoring and Artifacts

Statuses reported during deployment: `pending` → `building` → `deploying` → `success` (or `failed`).

```
Deployment queued...
Building deployment...
Deploying to infrastructure...
Deployment completed successfully!

Environment: production
Deployment ID: dep_abc123
URL: https://my-project.production.cirron.com
Deploy time: 2m 15s
```

Artifacts are read from `build.outputDir` and uploaded in batches of 5. The following files are filtered out automatically: `.DS_Store`, `Thumbs.db`, `.git/`, `node_modules/`, `.env`, `*.log`.

## Troubleshooting

| Error                                     | Resolution                                                |
| ----------------------------------------- | --------------------------------------------------------- |
| `No cirron.yaml found`                    | `cirron init my-project`                                  |
| `Not authenticated`                       | `cirron auth login`                                       |
| `Environment 'production' not found`      | Add it under `environments` in `cirron.yaml`              |
| `Build failed`                            | Run `cirron build --env production` separately to debug   |
| `No previous successful deployment found` | Rollback requires at least two successful deployments     |
| Deployment timeout                        | Check `cirron logs --env <env>` and infrastructure status |
| Network / auth expired                    | Re-authenticate; verify `cirron config --get apiUrl`      |

## Best Practices and CI/CD

* Always test in staging before production. Use descriptive `--message` values for audit.
* Use `beforeDeploy` for validation, `afterDeploy` for notifications.
* Keep a rollback strategy ready for production.

```yaml theme={null}
# GitHub Actions
- name: Deploy to Staging
  run: cirron deploy --env staging --message "CI/CD deployment" --force

- name: Deploy to Production
  run: cirron deploy --env production --message "Release ${{ github.ref_name }}" --force
```

## Related Commands

* **cirron build** - Build project before deployment
* **cirron logs** - View deployment logs
* **cirron auth** - Manage authentication
* **cirron status** - Check deployment status
