Deploy pipeline
A CI/CD run: the commit’s message, author, Code SHA and branch; four stages from build to production with a status icon and duration for each; a monospace log in a Pre for the selected stage; and Retry and Promote Buttons, with a Modal to confirm before production. A Spinner marks the stage that’s running.
Run #1,482 · fernhill-web
Cache compiled templates between requests
Stages
Test log
$ bun test --coverage✓ templates/render.test.ts (14 tests) 212ms✗ templates/cache.test.ts > evicts entries after the TTL Expected: undefined Received: "<h1>Hello, Ada</h1>" at templates/cache.test.ts:48:22Tests: 1 failed, 22 passed, 23 totalError: process exited with code 1Source · recipes/deploy-pipeline.tsx
'use client'
import { Button, Card, Code, Heading, Modal, Pre, Spinner, Stack, Text, toastSuccess } from '@blocks/design-system'
import { CheckCircle2, CircleDashed, GitBranch, Hand, RotateCcw, Rocket, XCircle } from 'lucide-react'
import { type FormEvent, useEffect, useId, useState } from 'react'
import styles from './deploy-pipeline.module.css'
type StageStatus = 'passed' | 'running' | 'waiting' | 'approval' | 'failed'
type StageId = 'build' | 'test' | 'preview' | 'production'
interface Stage {
id: StageId
name: string
status: StageStatus
duration?: string
}
const statusLabel: Record<StageStatus, string> = {
passed: 'Passed',
running: 'Running',
waiting: 'Waiting',
approval: 'Needs approval',
failed: 'Failed',
}
const logs: Record<StageId, Partial<Record<StageStatus, string[]>>> = {
build: {
passed: ['$ bun install --frozen-lockfile', 'Installed 412 packages in 3.1s', '$ bun run build', 'Compiled 186 modules in 41s', 'Wrote .output (14.2 MB)'],
},
test: {
failed: [
'$ bun test --coverage',
'✓ templates/render.test.ts (14 tests) 212ms',
'✗ templates/cache.test.ts > evicts entries after the TTL',
' Expected: undefined',
' Received: "<h1>Hello, Ada</h1>"',
' at templates/cache.test.ts:48:22',
'Tests: 1 failed, 22 passed, 23 total',
'Error: process exited with code 1',
],
running: ['$ bun test --coverage', '✓ templates/render.test.ts (14 tests) 208ms', 'Running templates/cache.test.ts…'],
passed: ['$ bun test --coverage', '✓ templates/render.test.ts (14 tests) 208ms', '✓ templates/cache.test.ts (9 tests) 1.02s', 'Tests: 23 passed, 23 total'],
},
preview: {
running: ['Uploading .output to preview…', 'Starting 2 instances in iad1'],
passed: ['Uploaded .output (14.2 MB)', 'Started 2 instances in iad1', 'Ready at https://a41f9c2.preview.fernhill.example'],
},
production: {
running: ['Promoting a41f9c2 to production…', 'Draining 6 old instances'],
passed: ['Started 6 instances in iad1, fra1, syd1', 'Shifted 100% of traffic to a41f9c2', 'Live at https://fernhill.example'],
},
}
const initialStages: Stage[] = [
{ id: 'build', name: 'Build', status: 'passed', duration: '1m 12s' },
{ id: 'test', name: 'Test', status: 'failed', duration: '2m 48s' },
{ id: 'preview', name: 'Preview', status: 'waiting' },
{ id: 'production', name: 'Production', status: 'waiting' },
]
const order = initialStages.map((stage) => stage.id)
// How long a simulated stage takes, and what it reports when it finishes.
const runTime = 2400
const finishedDurations: Record<StageId, string> = { build: '1m 12s', test: '2m 51s', preview: '38s', production: '1m 04s' }
export default function DeployPipeline() {
const [stages, setStages] = useState(initialStages)
const [openLog, setOpenLog] = useState<StageId | null>('test')
const [confirming, setConfirming] = useState(false)
const id = useId()
const running = stages.find((stage) => stage.status === 'running')
const failed = stages.find((stage) => stage.status === 'failed')
const awaitingApproval = stages.find((stage) => stage.status === 'approval')
// Stands in for the CI server: a running stage finishes after a moment, and
// the preview deploy starts on its own while production waits for a person.
useEffect(() => {
if (!running) return
const timer = setTimeout(() => {
const next = order[order.indexOf(running.id) + 1]
setStages((current) =>
current.map((stage) => {
if (stage.id === running.id) return { ...stage, status: 'passed', duration: finishedDurations[stage.id] }
if (stage.id === next) return { ...stage, status: next === 'production' ? 'approval' : 'running' }
return stage
}),
)
if (next && next !== 'production') setOpenLog(next)
if (running.id === 'production') toastSuccess('a41f9c2 is live in production')
}, runTime)
return () => clearTimeout(timer)
}, [running])
function start(stageId: StageId) {
setStages((current) => current.map((stage) => (stage.id === stageId ? { ...stage, status: 'running', duration: undefined } : stage)))
setOpenLog(stageId)
}
function promote(event: FormEvent<HTMLFormElement>) {
event.preventDefault()
if (!confirming) return
setConfirming(false)
start('production')
}
const logStage = stages.find((stage) => stage.id === openLog)
const logLines = logStage ? logs[logStage.id][logStage.status] : undefined
return (
<Stack gap="lg" dangerouslySetClassName={styles.pipeline}>
<Card as="header" padding="lg">
<Stack gap="md">
<Stack gap="xs">
<Text fontSize="sm" color="text-muted">
Run #1,482 · fernhill-web
</Text>
<Heading as="h2" fontSize="lg">
Cache compiled templates between requests
</Heading>
</Stack>
<Stack direction="row" gap="md" align="center" wrap="wrap">
<span className={styles.meta}>
<span className={styles.avatar} aria-hidden>
PN
</span>
<Text fontSize="sm">Priya Natarajan</Text>
</span>
<span className={styles.meta}>
<span className="visually-hidden">Commit</span>
<Code fontSize="xs" dangerouslySetClassName={styles.sha}>
a41f9c2
</Code>
</span>
<Text fontSize="sm" color="text-muted" dangerouslySetClassName={styles.meta}>
<GitBranch aria-hidden size={14} />
<span className="visually-hidden">Branch</span>
main
</Text>
<Text fontSize="sm" color="text-muted">
<time dateTime="2026-12-02T14:06:00Z">Pushed 6 minutes ago</time>
</Text>
</Stack>
</Stack>
</Card>
<Stack as="section" gap="md" aria-labelledby={`${id}-stages`}>
<Heading as="h3" id={`${id}-stages`} fontSize="md">
Stages
</Heading>
<ol className={styles.stages}>
{stages.map((stage) => {
const hasLog = Boolean(logs[stage.id][stage.status])
return (
<li key={stage.id} className={styles.stage} data-status={stage.status}>
<button
type="button"
className={styles.stageButton}
aria-expanded={hasLog ? openLog === stage.id : undefined}
aria-controls={hasLog ? `${id}-log` : undefined}
disabled={!hasLog}
onClick={() => setOpenLog(openLog === stage.id ? null : stage.id)}
>
<StatusIcon status={stage.status} />
<span className={styles.stageText}>
<Text fontSize="sm" fontWeight="semibold">
{stage.name}
</Text>
<Text fontSize="xs" color="text-muted">
{statusLabel[stage.status]}
</Text>
{stage.duration && (
<Text fontSize="xs" color="text-muted" dangerouslySetClassName={styles.duration}>
<span className="visually-hidden">Took </span>
{stage.duration}
</Text>
)}
</span>
</button>
</li>
)
})}
</ol>
</Stack>
{logStage && logLines && (
<Stack as="section" id={`${id}-log`} gap="sm" aria-labelledby={`${id}-log-title`}>
<Stack direction="row" justify="space-between" align="center" gap="sm">
<Heading as="h3" id={`${id}-log-title`} fontSize="sm">
{logStage.name} log
</Heading>
{logStage.status === 'running' && <Spinner size="sm" label={`${logStage.name} is running`} />}
</Stack>
<Pre tabIndex={0} aria-label={`${logStage.name} log output`} margin="none" dangerouslySetClassName={styles.log}>
<code>
{logLines.map((line, index) => (
<span
// biome-ignore lint/suspicious/noArrayIndexKey: log lines are append-only and can repeat
key={index}
className={styles.logLine}
data-tone={line.startsWith('✗') || line.startsWith('Error') ? 'error' : line.startsWith('$') ? 'command' : undefined}
>
<span className={styles.lineNumber} aria-hidden>
{index + 1}
</span>
{line}
</span>
))}
</code>
</Pre>
</Stack>
)}
<div className={styles.actions}>
<Button type="button" disabled={!failed || Boolean(running)} onClick={() => failed && start(failed.id)}>
<RotateCcw aria-hidden size={14} />
Retry {failed ? failed.name.toLowerCase() : 'failed stage'}
</Button>
<Modal open={confirming} onOpenChange={setConfirming}>
<Modal.Trigger disabled={!awaitingApproval} render={<Button type="button" variant="primary" />}>
<Rocket aria-hidden size={14} />
Promote to production
</Modal.Trigger>
<Modal.Content>
<Modal.Header>Promote a41f9c2 to production?</Modal.Header>
<Stack as="form" gap="md" onSubmit={promote}>
<Modal.Body>
fernhill.example will serve this build to every customer within about a minute. The current release stays available for instant
rollback.
</Modal.Body>
<Modal.Footer>
<Modal.Close render={<Button type="button" variant="ghost" />}>Cancel</Modal.Close>
<Button type="submit" variant="primary">
Promote
</Button>
</Modal.Footer>
</Stack>
</Modal.Content>
</Modal>
</div>
</Stack>
)
}
// Each status has its own shape, not only its own color.
function StatusIcon({ status }: { status: StageStatus }) {
// The stage's text already says "Running", so the spinner stays silent.
if (status === 'running') return <Spinner size="sm" aria-hidden />
const Icon = { passed: CheckCircle2, failed: XCircle, approval: Hand, waiting: CircleDashed }[status]
return <Icon aria-hidden size={18} className={styles.icon} />
}How it works
- It runs. Retry restarts the failed Test stage; when it passes, the preview deploy starts on its own and production waits for approval. Promote asks first, then deploys and confirms with a toast. A timer stands in for the CI server, and the initial state is fixed so the page renders the same on the server and in the browser.
- Stages are disclosure buttons. Each stage with a log is a
<button>witharia-expandedthat controls the single log panel; the log follows the stage that’s running. Stages without output yet are disabled. The open stage gets a heavier border in its own color: neutral, or red on the failed stage. - Status has a shape and a word. Passed, failed, waiting and needs-approval each have their own icon and label, and a running stage shows a spinner beside the word “Running”. The spinner in the stage is hidden from assistive technology so the state isn’t announced twice.
- It reflows. A container query lays the stages out in a row with connectors when there’s room and as a vertical list on a phone, where the actions stack at full width. The log scrolls inside itself.
App-owned CSS
The stage cards and connectors, status colors and the log’s line numbers.
.pipeline {
container-type: inline-size;
}
.meta {
display: inline-flex;
align-items: center;
gap: var(--ds-space-sm);
}
.avatar {
display: inline-flex;
align-items: center;
justify-content: center;
width: calc(var(--ds-space-lg) + var(--ds-space-md));
height: calc(var(--ds-space-lg) + var(--ds-space-md));
border-radius: var(--ds-border-radius-circle);
background-color: var(--ds-color-accent-subtle);
color: var(--ds-color-accent-text);
font-size: var(--ds-font-size-xxs);
font-weight: var(--ds-font-weight-semibold);
}
.sha {
padding: var(--ds-space-xxs) var(--ds-space-sm);
border-radius: var(--ds-border-radius-sm);
background-color: var(--ds-color-surface);
}
/* Stages read left to right with connectors between them; top to bottom on a phone. */
.stages {
display: flex;
flex-direction: column;
gap: var(--ds-space-lg);
margin: 0;
padding: 0;
list-style: none;
}
.stage {
position: relative;
flex: 1;
min-width: 0;
&:not(:last-child)::after {
content: "";
position: absolute;
top: 100%;
left: calc(var(--ds-space-lg) + var(--ds-space-xs));
width: var(--ds-border-width-md);
height: var(--ds-space-lg);
background-color: var(--ds-color-border);
}
&[data-status="passed"]:not(:last-child)::after {
background-color: var(--ds-color-success);
}
}
@container (min-width: 34rem) {
.stages {
flex-direction: row;
gap: var(--ds-space-lg);
}
.stage:not(:last-child)::after {
top: 50%;
left: 100%;
width: var(--ds-space-lg);
height: var(--ds-border-width-md);
}
}
.stageButton {
display: flex;
align-items: flex-start;
gap: var(--ds-space-md);
width: 100%;
height: 100%;
padding: var(--ds-space-md) calc(var(--ds-space-md) + var(--ds-space-sm));
border: var(--ds-border-width-sm) solid var(--ds-color-border-subtle);
border-radius: var(--ds-border-radius-md);
background-color: var(--ds-color-bg);
color: var(--ds-color-text);
font: inherit;
text-align: left;
cursor: pointer;
&:hover:not(:disabled) {
background-color: var(--ds-color-surface-hover);
}
&:disabled {
cursor: default;
}
/* The open stage gets a heavier border in its own color: neutral, or red when it failed. */
&[aria-expanded="true"] {
border-color: var(--ds-color-border-strong);
box-shadow: 0 0 0 var(--ds-border-width-sm) var(--ds-color-border-strong);
}
&:focus-visible {
outline: var(--ds-border-width-md) solid var(--ds-color-focus-ring);
outline-offset: var(--ds-border-width-md);
}
.stage[data-status="failed"] & {
border-color: color-mix(in srgb, var(--ds-color-danger) 50%, transparent);
background-color: var(--ds-color-danger-subtle);
}
.stage[data-status="failed"] &[aria-expanded="true"] {
border-color: var(--ds-color-danger);
box-shadow: 0 0 0 var(--ds-border-width-sm) var(--ds-color-danger);
}
.stage[data-status="waiting"] & {
border-style: dashed;
}
}
.stageText {
display: flex;
flex-direction: column;
min-width: 0;
}
.duration {
font-variant-numeric: tabular-nums;
white-space: nowrap;
}
.icon {
flex-shrink: 0;
margin-top: var(--ds-space-xxs);
.stage[data-status="passed"] & {
color: var(--ds-color-success-text);
}
.stage[data-status="failed"] & {
color: var(--ds-color-danger-text);
}
.stage[data-status="approval"] & {
color: var(--ds-color-warning-text);
}
.stage[data-status="waiting"] & {
color: var(--ds-color-text-muted);
}
}
/* A quiet terminal: long lines and long logs scroll inside it, never the page. */
.log {
max-height: 16rem;
padding: var(--ds-space-md) 0;
overflow: auto;
border: var(--ds-border-width-sm) solid var(--ds-color-border-subtle);
border-radius: var(--ds-border-radius-md);
background-color: var(--ds-color-bg-subtle);
font-family: var(--ds-font-monospace);
font-size: var(--ds-font-size-code);
line-height: var(--ds-line-height-body);
& code {
display: block;
min-width: max-content;
}
&:focus-visible {
outline: var(--ds-border-width-md) solid var(--ds-color-focus-ring);
outline-offset: var(--ds-border-width-sm);
}
}
.logLine {
display: block;
padding-right: var(--ds-space-lg);
&[data-tone="command"] {
color: var(--ds-color-text-muted);
}
&[data-tone="error"] {
background-color: var(--ds-color-danger-subtle);
color: var(--ds-color-danger-text);
}
}
.lineNumber {
display: inline-block;
width: var(--ds-space-xl);
margin-right: var(--ds-space-md);
color: var(--ds-color-text-muted);
text-align: right;
user-select: none;
opacity: 0.6;
}
/* Actions sit at the end of a row; on a phone they stack at full width. */
.actions {
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: var(--ds-space-sm);
}
@container (max-width: 30rem) {
.actions {
flex-direction: column;
align-items: stretch;
}
}