# Deploy gate with buttons

Shows that a release is ready and lets the user ship or hold it from the widget.

**Sizes:** small (the headline), medium and large (headline, test result, buttons)
**Interaction:** buttons, answered by a listener (listen.mjs here)
**Rule:** deploying is consequential. The widget names the version and the target, so "Ship" is the user's approval. If anything about the deploy isn't on the widget (a migration, a different target), confirm with `droplet_ask` first. After the tap: Sent, then "Shipping…", then the result with the next step.

## Widget

```json
{
  "slug": "deploy-gate",
  "title": "Deploy gate",
  "symbol": "shippingbox.fill",
  "accent": "#FF9F0A",
  "blocks": [
    { "type": "metric", "label": "Tests", "value": "247/247" },
    { "type": "text", "text": "v2.4.1 is ready to ship to production. Ship it?" },
    { "type": "buttons", "color": "#30D158", "items": [
      { "id": "ship", "label": "Ship", "symbol": "paperplane.fill" },
      { "id": "hold", "label": "Hold", "symbol": "pause.fill" },
      { "label": "Logs", "symbol": "doc.text", "url": "https://ci.example.com/runs/42" }
    ] },
    { "type": "list", "title": "In v2.4.1", "items": [
      "Faster sign-in",
      "Fix: CSV export dates",
      "New billing page"
    ] }
  ],
  "sizes": { "small": [1], "large": [1, 0, 3, 2] },
  "lock": { "circular": 0, "inline": "v2.4.1 ready to ship" }
}
```

Medium has no `sizes`, so it splits: the test count on the left, the offer on the right, and the buttons pinned to the bottom (about 50 pt is left above them). Small shows the sentence; large adds what's in the release. The round Lock Screen widget shows the test count. The "Logs" button opens a page and sends no event.

## Handler

```bash
DROPLET_TOKEN=dp_... node listen.mjs --widget deploy-gate --on-tap ./deploy-handler.sh
```

```bash
#!/usr/bin/env bash
# deploy-handler.sh: each line replaces the first three blocks; the release list (block 3) is kept
# because every line sends all four in the same order.
target=$(python3 -c "import sys,json; print(json.load(sys.stdin)['target'])")
LOGS='{"type":"buttons","items":[{"label":"Logs","symbol":"doc.text","url":"https://ci.example.com/runs/42"}]}'
LIST='{"type":"list","title":"In v2.4.1","items":["Faster sign-in","Fix: CSV export dates","New billing page"]}'
widget() { echo "{\"blocks\":[{\"type\":\"metric\",\"label\":\"$1\",\"value\":\"$2\"},{\"type\":\"text\",\"text\":\"$3\"},$LOGS,$LIST]}"; }

case "$target" in
  ship)
    widget "Status" "Started" "Shipping v2.4.1 to production. This widget changes when it's live."
    if gh workflow run deploy.yml --ref main >/dev/null 2>&1; then
      widget "Status" "Running" "v2.4.1 is shipping to production. I'll put the result here."
    else
      widget "Status" "Failed" "The deploy didn't start. Open the logs to see why."
    fi
    ;;
  hold)
    widget "Status" "On hold" "v2.4.1 is on hold. Nothing was deployed to production."
    ;;
esac
```

Each line keeps the same four blocks in the same order, so `sizes` and `lock` stay valid. Status words are short ("Running") because the metric shows about 8 characters. When the deploy finishes, your CI calls `set_widget` again with the result.

## When the next release is ready

```json
{
  "slug": "deploy-gate",
  "title": "Deploy gate",
  "blocks": [
    { "type": "metric", "label": "Tests", "value": "251/251" },
    { "type": "text", "text": "v2.5.0 is ready to ship to production. Ship it?" },
    { "type": "buttons", "color": "#30D158", "items": [
      { "id": "ship", "label": "Ship", "symbol": "paperplane.fill" },
      { "id": "hold", "label": "Hold", "symbol": "pause.fill" },
      { "label": "Logs", "symbol": "doc.text", "url": "https://ci.example.com/runs/43" }
    ] },
    { "type": "list", "title": "In v2.5.0", "items": [
      "Team invites",
      "Dark mode for reports",
      "Fix: timezone in exports"
    ] }
  ],
  "sizes": { "small": [1], "large": [1, 0, 3, 2] },
  "lock": { "circular": 0, "inline": "v2.5.0 ready to ship" },
  "relevance": 80
}
```

`relevance` 80 lifts it to the top of a Smart Stack while it waits; set it back to 20 after.
