Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Merge main: Deployments panel in the About, project homepage, both sides' operations | 1 | import { ArrowLeft, ChevronRight, ExternalLink, FileText, GitBranch, GitCommitHorizontal, Workflow } from "lucide-react"; |
| 2 | import type { ReactNode } from "react"; | |
| Deployments: a preview for every pull request, production on g1t.page | 3 | import { Link, data } from "react-router"; |
| 4 | ||
| Merge main: Deployments panel in the About, project homepage, both sides' operations | 5 | import type { Deployment, DeploymentDetail, DeploymentStatus } from "@g1t/contracts"; |
| 6 | ||
| Deployments: a preview for every pull request, production on g1t.page | 7 | import type { Route } from "./+types/deployment"; |
| Social cards for every page: og.g1t.sh | 8 | import { page } from "../../lib/meta"; |
| Deployments: a preview for every pull request, production on g1t.page | 9 | import { TimeAgo } from "../../components/ui"; |
| Merge main: Deployments panel in the About, project homepage, both sides' operations | 10 | import { Badge } from "../../components/ui/badge"; |
| 11 | import { Hint } from "../../components/ui/hint"; | |
| 12 | import { host } from "../../components/deploy"; | |
| 13 | import { DeploymentStateBadge, DeploymentStateIcon, STATE_TONE, sourceLabel } from "../../components/deployments-panel"; | |
| Deployments: a preview for every pull request, production on g1t.page | 14 | import { deployments } from "../../lib/services.server"; |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 15 | import { getViewer } from "../../lib/session.server"; |
| 16 | import { requireRepo } from "../../lib/access.server"; | |
| Merge main: Deployments panel in the About, project homepage, both sides' operations | 17 | import { STATE_WORD, buildError, environmentLabel, hasPayload, isPageBuild, shortSha } from "../../lib/deployments"; |
| Deployments: a preview for every pull request, production on g1t.page | 18 | |
| Social cards for every page: og.g1t.sh | 19 | export function meta({ params, ...args }: Route.MetaArgs) { |
| 20 | return page(args, { title: `Deployment · ${params.owner}/${params.repo} · g1t` }); | |
| Deployments: a preview for every pull request, production on g1t.page | 21 | } |
| 22 | ||
| 23 | export async function loader({ params, context }: Route.LoaderArgs) { | |
| 24 | const viewer = getViewer(context); | |
| Merge main: Deployments panel in the About, project homepage, both sides' operations | 25 | const { repo } = await requireRepo(context, params, "read"); |
| 26 | const path = { namespace: repo.namespace, name: repo.name }; | |
| 27 | const soft = <T,>(promise: Promise<T>): Promise<T | null> => | |
| 28 | promise.catch((error) => (console.warn("deployment:", error), null)); | |
| 29 | // A g1t.page build also has its build log and warnings, for the workspace's members. | |
| 30 | const [found, build] = await Promise.all([ | |
| 31 | soft(deployments.repoDeployment(path, params.id, viewer)), | |
| 32 | isPageBuild(params.id) ? soft(deployments.get({ workspace: params.owner, slug: params.repo }, params.id, viewer)) : null, | |
| 33 | ]); | |
| 34 | const deployment = found?.ok ? found.value : null; | |
| 35 | const pageBuild = build?.ok ? build.value : null; | |
| 36 | if (!deployment && !pageBuild) throw data(null, { status: 404 }); | |
| 37 | return { deployment, build: pageBuild }; | |
| Deployments: a preview for every pull request, production on g1t.page | 38 | } |
| 39 | ||
| Merge main: Deployments panel in the About, project homepage, both sides' operations | 40 | /** A g1t.page build's status in words. */ |
| 41 | const BUILD_WORDS = { | |
| Deployments: a preview for every pull request, production on g1t.page | 42 | queued: "Waiting for a sandbox", |
| 43 | building: "Building", | |
| 44 | ready: "Live", | |
| Builds say Replaced or Down once they are no longer live | 45 | replaced: "Replaced by a newer build", |
| 46 | down: "Taken down", | |
| Deployments: a preview for every pull request, production on g1t.page | 47 | failed: "Failed", |
| 48 | skipped: "Skipped", | |
| 49 | } as const; | |
| 50 | ||
| 51 | export default function DeploymentPage({ loaderData, params }: Route.ComponentProps) { | |
| Merge main: Deployments panel in the About, project homepage, both sides' operations | 52 | const { deployment, build } = loaderData; |
| Deployments: a preview for every pull request, production on g1t.page | 53 | const base = `/${params.owner}/${params.repo}`; |
| 54 | return ( | |
| 55 | <div className="mx-auto max-w-5xl"> | |
| 56 | <Link to={`${base}/deployments`} className="inline-flex items-center gap-1 text-sm text-muted hover:text-fg"> | |
| 57 | <ArrowLeft size={14} /> | |
| 58 | Deployments | |
| 59 | </Link> | |
| Merge main: Deployments panel in the About, project homepage, both sides' operations | 60 | {deployment ? <Reported deployment={deployment} base={base} /> : build && <BuildHeading build={build} base={base} />} |
| 61 | {build && <BuildDetails build={build} />} | |
| 62 | </div> | |
| 63 | ); | |
| 64 | } | |
| 65 | ||
| 66 | function Reported({ deployment, base }: { deployment: DeploymentDetail; base: string }) { | |
| 67 | const url = deployment.environment_url; | |
| 68 | const environmentTo = `${base}/deployments?environment=${encodeURIComponent(deployment.environment)}#history`; | |
| 69 | return ( | |
| 70 | <> | |
| 71 | <header className="mt-3 flex flex-wrap items-start justify-between gap-4"> | |
| 72 | <div className="min-w-0"> | |
| 73 | <h1 className="flex flex-wrap items-center gap-x-3 gap-y-1 text-xl font-semibold tracking-tight"> | |
| 74 | <Link to={environmentTo} className="hover:text-accent"> | |
| 75 | {environmentLabel(deployment.environment)} | |
| 76 | </Link> | |
| 77 | {deployment.number != null && ( | |
| 78 | <Link to={`${base}/pull/${deployment.number}`} className="text-base font-normal text-muted hover:underline"> | |
| 79 | #{deployment.number} | |
| 80 | </Link> | |
| 81 | )} | |
| 82 | <DeploymentStateBadge state={deployment.state} size={16} className="text-sm" /> | |
| 83 | </h1> | |
| 84 | <p className="mt-1 text-sm text-muted"> | |
| 85 | {deployment.task === "deploy" ? "Deployment" : <span className="font-mono">{deployment.task}</span>} of{" "} | |
| 86 | <span className="font-mono text-fg-soft">{deployment.ref}</span> by{" "} | |
| 87 | <span className="text-fg-soft">{deployment.creator}</span> via {sourceLabel(deployment.source)},{" "} | |
| 88 | <TimeAgo at={deployment.created_at} /> | |
| 89 | </p> | |
| 90 | </div> | |
| 91 | {url && ( | |
| 92 | <a | |
| 93 | href={url} | |
| 94 | className="inline-flex max-w-full items-center gap-1.5 rounded-md bg-accent px-3.5 py-2 text-sm font-medium text-bg hover:bg-accent-hover" | |
| 95 | > | |
| 96 | <span className="truncate">{host(url)}</span> | |
| 97 | <ExternalLink size={14} className="shrink-0" /> | |
| 98 | </a> | |
| 99 | )} | |
| 100 | </header> | |
| 101 | ||
| 102 | {deployment.description && ( | |
| 103 | <p className="mt-4 max-w-3xl text-sm text-fg-soft [overflow-wrap:anywhere]">{deployment.description}</p> | |
| 104 | )} | |
| 105 | ||
| 106 | <dl className="mt-6 grid grid-cols-1 gap-px overflow-hidden rounded-xl border border-line bg-line text-sm sm:grid-cols-2 lg:grid-cols-4"> | |
| 107 | <Fact label="Environment"> | |
| 108 | <Link to={environmentTo} className="hover:text-accent"> | |
| 109 | {environmentLabel(deployment.environment)} | |
| 110 | </Link> | |
| 111 | {deployment.production_environment && deployment.environment !== "production" && <Badge tone="accent">Production</Badge>} | |
| 112 | {deployment.transient_environment && <Badge>Transient</Badge>} | |
| 113 | </Fact> | |
| 114 | <Fact label="Commit"> | |
| 115 | <Link to={`${base}/commit/${deployment.sha}`} className="inline-flex items-center gap-1 font-mono hover:text-accent"> | |
| 116 | <GitCommitHorizontal size={13} className="text-faint" /> | |
| 117 | {shortSha(deployment.sha)} | |
| 118 | </Link> | |
| 119 | <span className="inline-flex min-w-0 items-center gap-1 font-mono text-muted"> | |
| 120 | <GitBranch size={12} className="shrink-0 text-faint" /> | |
| 121 | <span className="truncate">{deployment.ref}</span> | |
| 122 | </span> | |
| 123 | </Fact> | |
| 124 | <Fact label="Made by"> | |
| 125 | <span className="truncate">{deployment.creator}</span> | |
| 126 | <span className="text-muted"> | |
| 127 | via{" "} | |
| 128 | {deployment.source === "actions" && deployment.run_url ? ( | |
| 129 | <Link to={deployment.run_url} className="text-fg-soft hover:text-accent hover:underline"> | |
| 130 | {sourceLabel(deployment.source)} | |
| 131 | </Link> | |
| 132 | ) : ( | |
| 133 | sourceLabel(deployment.source) | |
| 134 | )} | |
| 135 | </span> | |
| 136 | </Fact> | |
| 137 | <Fact label="Updated"> | |
| 138 | <TimeAgo at={deployment.updated_at} /> | |
| 139 | <span className="text-muted"> | |
| 140 | created <TimeAgo at={deployment.created_at} /> | |
| 141 | </span> | |
| 142 | </Fact> | |
| 143 | </dl> | |
| 144 | ||
| 145 | {(deployment.log_url || deployment.run_url) && ( | |
| 146 | <p className="mt-3 flex flex-wrap gap-x-5 gap-y-1 text-sm"> | |
| 147 | {deployment.run_url && deployment.source === "actions" && ( | |
| 148 | <Link to={deployment.run_url} className="inline-flex items-center gap-1.5 text-muted hover:text-fg"> | |
| 149 | <Workflow size={14} className="text-faint" /> | |
| 150 | Workflow run | |
| 151 | </Link> | |
| 152 | )} | |
| 153 | {deployment.log_url && !isPageBuild(deployment.id) && ( | |
| 154 | <a href={deployment.log_url} className="inline-flex items-center gap-1.5 text-muted hover:text-fg"> | |
| 155 | <FileText size={14} className="text-faint" /> | |
| 156 | Log | |
| 157 | <ExternalLink size={12} className="text-faint" /> | |
| 158 | </a> | |
| 159 | )} | |
| 160 | </p> | |
| 161 | )} | |
| 162 | ||
| 163 | <section aria-labelledby="statuses" className="mt-8"> | |
| 164 | <h2 id="statuses" className="text-sm font-semibold"> | |
| 165 | Statuses <span className="font-normal text-faint">{deployment.statuses.length}</span> | |
| 166 | </h2> | |
| 167 | {deployment.statuses.length === 0 ? ( | |
| 168 | <p className="mt-3 text-sm text-muted">No statuses yet.</p> | |
| 169 | ) : ( | |
| 170 | <ol className="mt-4"> | |
| 171 | {deployment.statuses.map((status, index) => ( | |
| 172 | <StatusItem key={status.id} status={status} last={index === deployment.statuses.length - 1} /> | |
| 173 | ))} | |
| 174 | </ol> | |
| 175 | )} | |
| 176 | </section> | |
| 177 | ||
| 178 | {hasPayload(deployment.payload) && ( | |
| 179 | <details className="group mt-8 rounded-xl border border-line bg-surface"> | |
| 180 | <summary className="flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-semibold [&::-webkit-details-marker]:hidden"> | |
| 181 | <ChevronRight size={14} className="text-faint transition-transform group-open:rotate-90" /> | |
| 182 | Payload | |
| 183 | <span className="font-normal text-faint">{Object.keys(deployment.payload).length} keys</span> | |
| 184 | </summary> | |
| 185 | <pre className="max-h-[60vh] overflow-auto border-t border-line p-4 font-mono text-xs leading-relaxed text-muted whitespace-pre-wrap [overflow-wrap:anywhere]"> | |
| 186 | {JSON.stringify(deployment.payload, null, 2)} | |
| 187 | </pre> | |
| 188 | </details> | |
| 189 | )} | |
| 190 | </> | |
| 191 | ); | |
| 192 | } | |
| 193 | ||
| 194 | function Fact({ label, children }: { label: string; children: ReactNode }) { | |
| 195 | return ( | |
| 196 | <div className="min-w-0 bg-surface px-4 py-3"> | |
| 197 | <dt className="text-[0.6875rem] text-faint">{label}</dt> | |
| 198 | <dd className="mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5">{children}</dd> | |
| 199 | </div> | |
| 200 | ); | |
| 201 | } | |
| 202 | ||
| 203 | /** One status on the timeline, oldest at the top, with a line down to the next. */ | |
| 204 | function StatusItem({ status, last }: { status: DeploymentStatus; last: boolean }) { | |
| 205 | return ( | |
| 206 | <li className="relative flex gap-3 pb-5 last:pb-0"> | |
| 207 | {!last && <span aria-hidden="true" className="absolute top-6 bottom-1 left-[9px] w-px bg-line" />} | |
| 208 | <span className="relative mt-0.5 flex size-[19px] shrink-0 items-center justify-center bg-bg"> | |
| 209 | <DeploymentStateIcon state={status.state} size={18} /> | |
| 210 | </span> | |
| 211 | <div className="min-w-0 grow"> | |
| 212 | <p className="flex flex-wrap items-baseline gap-x-2 text-sm"> | |
| 213 | <span className={`font-medium ${STATE_TONE[status.state]}`}>{STATE_WORD[status.state]}</span> | |
| 214 | <span className="text-xs text-faint"> | |
| 215 | {status.creator} ·{" "} | |
| 216 | <Hint label={new Date(status.created_at).toUTCString()}> | |
| 217 | <span tabIndex={0}> | |
| 218 | <TimeAgo at={status.created_at} /> | |
| 219 | </span> | |
| 220 | </Hint> | |
| 221 | </span> | |
| 222 | </p> | |
| 223 | {status.description && <p className="mt-0.5 text-sm text-muted [overflow-wrap:anywhere]">{status.description}</p>} | |
| 224 | {(status.environment_url || status.log_url) && ( | |
| 225 | <p className="mt-1 flex flex-wrap gap-x-4 gap-y-0.5 text-xs"> | |
| 226 | {status.environment_url && ( | |
| 227 | <a href={status.environment_url} className="inline-flex min-w-0 items-center gap-1 font-mono text-accent hover:underline"> | |
| 228 | <span className="truncate">{host(status.environment_url)}</span> | |
| 229 | <ExternalLink size={11} className="shrink-0" /> | |
| 230 | </a> | |
| 231 | )} | |
| 232 | {status.log_url && ( | |
| 233 | <a href={status.log_url} className="inline-flex items-center gap-1 text-muted hover:text-fg"> | |
| 234 | <FileText size={11} /> | |
| 235 | Log | |
| 236 | </a> | |
| 237 | )} | |
| 238 | </p> | |
| 239 | )} | |
| 240 | </div> | |
| 241 | </li> | |
| 242 | ); | |
| 243 | } | |
| 244 | ||
| 245 | /** A g1t.page build with no deployment record to head it: its own heading, as before. */ | |
| 246 | function BuildHeading({ build, base }: { build: Deployment; base: string }) { | |
| 247 | return ( | |
| 248 | <> | |
| Deployments: a preview for every pull request, production on g1t.page | 249 | <h1 className="mt-3 text-xl font-semibold tracking-tight"> |
| Merge main: Deployments panel in the About, project homepage, both sides' operations | 250 | {build.kind === "production" ? ( |
| 251 | "Production" | |
| 252 | ) : ( | |
| Deployments: a preview for every pull request, production on g1t.page | 253 | <> |
| Projects: what a workspace builds and runs, first on every page | 254 | Preview of <span className="font-mono">{build.branch}</span> |
| 255 | {build.number != null && ( | |
| 256 | <Link to={`${base}/pull/${build.number}`} className="ml-2 text-base font-normal text-muted hover:underline"> | |
| 257 | #{build.number} | |
| 258 | </Link> | |
| 259 | )} | |
| Deployments: a preview for every pull request, production on g1t.page | 260 | </> |
| 261 | )} | |
| 262 | <span className="ml-3 font-mono text-sm font-normal text-faint">{build.commit.slice(0, 12)}</span> | |
| 263 | </h1> | |
| 264 | <p className="mt-1 text-sm text-muted"> | |
| Merge main: Deployments panel in the About, project homepage, both sides' operations | 265 | {BUILD_WORDS[build.status]} · started <TimeAgo at={build.createdAt} /> by {build.createdBy} |
| Deployments: a preview for every pull request, production on g1t.page | 266 | </p> |
| 267 | {build.status === "ready" && ( | |
| 268 | <a href={build.url} className="mt-3 inline-flex items-center gap-1.5 font-mono text-sm text-accent hover:underline"> | |
| Merge main: Deployments panel in the About, project homepage, both sides' operations | 269 | {host(build.url)} |
| Deployments: a preview for every pull request, production on g1t.page | 270 | <ExternalLink size={12} /> |
| 271 | </a> | |
| 272 | )} | |
| Merge main: Deployments panel in the About, project homepage, both sides' operations | 273 | </> |
| 274 | ); | |
| 275 | } | |
| 276 | ||
| 277 | /** What only a g1t.page build has: why it failed, its warnings, and its build log. */ | |
| 278 | function BuildDetails({ build }: { build: Deployment & { log: string | null } }) { | |
| 279 | const error = buildError(build); | |
| 280 | return ( | |
| 281 | <section aria-labelledby="build" className="mt-8"> | |
| 282 | <h2 id="build" className="flex flex-wrap items-baseline gap-x-2 text-sm font-semibold"> | |
| 283 | Build on g1t.page | |
| 284 | <span className="text-xs font-normal text-muted"> | |
| 285 | {BUILD_WORDS[build.status]} | |
| 286 | {build.buildSeconds != null && ` · built in ${build.buildSeconds} s`} | |
| 287 | </span> | |
| 288 | </h2> | |
| Usage, Billing settings and prepaid AI credit; fixes from the UX audit | 289 | {error && ( |
| Merge main: Deployments panel in the About, project homepage, both sides' operations | 290 | <p className="mt-3 rounded-lg border border-danger/30 bg-danger/5 px-4 py-3 text-sm [overflow-wrap:anywhere]">{error}</p> |
| Deployments: a preview for every pull request, production on g1t.page | 291 | )} |
| 292 | {build.warnings.length > 0 && ( | |
| Merge main: Deployments panel in the About, project homepage, both sides' operations | 293 | <ul className="mt-3 space-y-1 rounded-lg border border-warn/30 bg-warn/5 px-4 py-3 text-sm"> |
| Deployments: a preview for every pull request, production on g1t.page | 294 | {build.warnings.map((warning) => ( |
| 295 | <li key={warning}>{warning}</li> | |
| 296 | ))} | |
| 297 | </ul> | |
| 298 | )} | |
| Merge main: Deployments panel in the About, project homepage, both sides' operations | 299 | <h3 className="mt-5 text-sm font-medium text-muted">Build log</h3> |
| Usage, Billing settings and prepaid AI credit; fixes from the UX audit | 300 | {/* Long lines wrap, so a narrow screen shows the whole log without scrolling sideways. */} |
| 301 | <pre className="mt-3 max-h-[70vh] overflow-auto whitespace-pre-wrap rounded-xl border border-line bg-bg p-4 font-mono text-xs leading-relaxed text-muted [overflow-wrap:anywhere]"> | |
| Deployments: a preview for every pull request, production on g1t.page | 302 | {build.log || (build.status === "queued" || build.status === "building" ? "The log appears when the build finishes." : "No log.")} |
| 303 | </pre> | |
| Merge main: Deployments panel in the About, project homepage, both sides' operations | 304 | </section> |
| Deployments: a preview for every pull request, production on g1t.page | 305 | ); |
| 306 | } |
This file's history is long; its oldest lines are credited to the oldest commit read.