# Workflows

Source: https://docs.ops0.com/docs/workflows/overview

Automate multi-step operations by chaining IaC deployments, configuration runs, scripts, and approvals into a single pipeline.

![ops0 Workflows list showing trigger types, status and execution history](https://docs.ops0.com/images/workflows-overview.png)

## Step Types

![ops0 Add Node dialog showing all workflow step types](https://docs.ops0.com/images/workflow-add-node.png)

IaC Deploy

Run Terraform/OpenTofu plan, apply, or destroy

Configuration Deploy

Run Ansible playbooks

Kubernetes Deployment

Deploy a project to a cluster

Script Execution

Execute bash, Python, or Node scripts

HTTP Request

Call external APIs or webhooks

Approval Gate

Pause for human approval

K8s Incidents

Gate on incident severity/cluster filters

## Trigger Types

Manual

User clicks Run

Webhook

HTTP POST trigger

One-time Schedule

Runs once at a specific date/time

Recurring (Cron)

Cron expression

---

## Workflow Status

| Status | Color | Meaning |
|--------|-------|---------|
| **Active** | Green | Workflow is enabled and will run on triggers |
| **Paused** | Yellow | Temporarily disabled, manual run only |
| **Draft** | Gray | Not yet activated |

## Workflow Actions

| Action | Description |
|--------|-------------|
| **Run** | Execute the workflow manually |
| **Edit** | Open in visual DAG builder |
| **Duplicate** | Create a copy |
| **View History** | See past executions |
| **Pause/Resume** | Toggle active state |
| **Delete** | Remove the workflow |

---

## Common Patterns

| Pattern | Steps |
|---------|-------|
| **Deploy Pipeline** | Plan → Approval → Apply → Notify |
| **Environment Promotion** | Dev → Test → Approval → Prod |
| **Scheduled Backup** | Script → Upload → Cleanup |
| **Incident Response** | Detect → Scale → Notify |
| **Multi-Region Deploy** | Plan → Apply US ∥ Apply EU → Verify |

---

## Example: CI/CD Deployment Pipeline

### Workflow Configuration

```
Name:        production-deploy
Trigger:     Webhook (triggered from GitHub Actions on main branch push)
Steps:       5
Status:      Active
```

### Visual Pipeline

```
┌─────────┐    ┌──────────┐    ┌──────────┐    ┌─────────┐    ┌────────┐
│  Plan   │───▶│ Approval │───▶│  Apply   │───▶│  Test   │───▶│ Notify │
└─────────┘    └──────────┘    └──────────┘    └─────────┘    └────────┘
```

### Step Configuration

| Step | Type | Configuration |
|------|------|---------------|
| Plan | IaC Deploy | Project: `api-infrastructure`, Action: Plan |
| Approval | Approval | Approvers: `team:platform`, Timeout: 1h |
| Apply | IaC Deploy | Project: `api-infrastructure`, Action: Apply |
| Test | HTTP Request | URL: `https://api.example.com/health` |
| Notify | Slack | Channel: `#deployments`, Message: Deploy complete |

### Execution Result

```
Workflow: production-deploy
Run ID:   wfr_8x7y6z5w
Status:   Completed ✓

Step Results:
─────────────────────────────────────
1. Plan         ✓  Completed    12s
   → 3 to add, 1 to change, 0 to destroy

2. Approval     ✓  Approved     4m 32s
   → Approved by jane@example.com

3. Apply        ✓  Completed    45s
   → 3 added, 1 changed, 0 destroyed

4. Test         ✓  Completed    2s
   → HTTP 200 OK

5. Notify       ✓  Completed    1s
   → Message sent to #deployments

Total Duration: 5m 32s
Triggered By:   Webhook (main @ abc1234)
```

### Slack Notification

```
🚀 Deployment Complete

Workflow: production-deploy
Environment: production
Status: Success ✓
Duration: 5m 32s

Changes Applied:
• 3 resources added
• 1 resource changed

Triggered by: jane@example.com
Commit: abc1234 "Add rate limiting to API"
```

---

## Example: Multi-Region Parallel Deploy

### Workflow with Parallel Steps

```
                    ┌─────────────┐
              ┌────▶│  Apply US   │────┐
┌─────────┐   │     └─────────────┘    │     ┌──────────┐
│  Plan   │───┤                        ├────▶│  Verify  │
└─────────┘   │     ┌─────────────┐    │     └──────────┘
              └────▶│  Apply EU   │────┘
                    └─────────────┘
```

### Execution Timeline

```
00:00  Plan started
00:15  Plan completed (3 resources)
00:15  Apply US started ─┬─ (parallel)
00:15  Apply EU started ─┘
00:45  Apply EU completed
00:52  Apply US completed
00:52  Verify started
00:55  Verify completed

Total: 55 seconds
```
