pr_01m47d15m3e54sn21z27rpy5n9/apps/web/app/routes/repo/deployment.tsx

81 lines3,386 bytesCodeBlame

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.

Deployments: a preview for every pull request, production on g1t.page1import { ArrowLeft, ExternalLink } from "lucide-react";
2import { Link, data } from "react-router";
3
4import type { Route } from "./+types/deployment";
Social cards for every page: og.g1t.sh5import { page } from "../../lib/meta";
Deployments: a preview for every pull request, production on g1t.page6import { TimeAgo } from "../../components/ui";
7import { deployments } from "../../lib/services.server";
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look8import { getViewer } from "../../lib/session.server";
9import { requireRepo } from "../../lib/access.server";
Deployments: a preview for every pull request, production on g1t.page10
Social cards for every page: og.g1t.sh11export function meta({ params, ...args }: Route.MetaArgs) {
12 return page(args, { title: `Deployment · ${params.owner}/${params.repo} · g1t` });
Deployments: a preview for every pull request, production on g1t.page13}
14
15export async function loader({ params, context }: Route.LoaderArgs) {
16 const viewer = getViewer(context);
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look17 await requireRepo(context, params, "read");
Projects: what a workspace builds and runs, first on every page18 const found = await deployments.get({ workspace: params.owner, slug: params.repo }, params.id, viewer);
Deployments: a preview for every pull request, production on g1t.page19 if (!found.ok) throw data(null, { status: 404 });
20 return { build: found.value };
21}
22
23const WORDS = {
24 queued: "Waiting for a sandbox",
25 building: "Building",
26 ready: "Live",
Builds say Replaced or Down once they are no longer live27 replaced: "Replaced by a newer build",
28 down: "Taken down",
Deployments: a preview for every pull request, production on g1t.page29 failed: "Failed",
30 skipped: "Skipped",
31} as const;
32
33export default function DeploymentPage({ loaderData, params }: Route.ComponentProps) {
34 const { build } = loaderData;
35 const base = `/${params.owner}/${params.repo}`;
36 return (
37 <div className="mx-auto max-w-5xl">
38 <Link to={`${base}/deployments`} className="inline-flex items-center gap-1 text-sm text-muted hover:text-fg">
39 <ArrowLeft size={14} />
40 Deployments
41 </Link>
42 <h1 className="mt-3 text-xl font-semibold tracking-tight">
43 {build.kind === "production" ? "Production" : (
44 <>
Projects: what a workspace builds and runs, first on every page45 Preview of <span className="font-mono">{build.branch}</span>
46 {build.number != null && (
47 <Link to={`${base}/pull/${build.number}`} className="ml-2 text-base font-normal text-muted hover:underline">
48 #{build.number}
49 </Link>
50 )}
Deployments: a preview for every pull request, production on g1t.page51 </>
52 )}
53 <span className="ml-3 font-mono text-sm font-normal text-faint">{build.commit.slice(0, 12)}</span>
54 </h1>
55 <p className="mt-1 text-sm text-muted">
56 {WORDS[build.status]} · started <TimeAgo at={build.createdAt} /> by {build.createdBy}
57 {build.buildSeconds != null && ` · built in ${build.buildSeconds} s`}
58 </p>
59 {build.status === "ready" && (
60 <a href={build.url} className="mt-3 inline-flex items-center gap-1.5 font-mono text-sm text-accent hover:underline">
61 {build.url.replace("https://", "")}
62 <ExternalLink size={12} />
63 </a>
64 )}
65 {build.error && (
66 <p className="mt-4 rounded-lg border border-danger/30 bg-danger/5 px-4 py-3 text-sm">{build.error}</p>
67 )}
68 {build.warnings.length > 0 && (
69 <ul className="mt-4 space-y-1 rounded-lg border border-warn/30 bg-warn/5 px-4 py-3 text-sm">
70 {build.warnings.map((warning) => (
71 <li key={warning}>{warning}</li>
72 ))}
73 </ul>
74 )}
75 <h2 className="mt-8 text-sm font-medium text-muted">Build log</h2>
76 <pre className="mt-3 max-h-[70vh] overflow-auto rounded-xl border border-line bg-bg p-4 font-mono text-xs leading-relaxed text-muted">
77 {build.log || (build.status === "queued" || build.status === "building" ? "The log appears when the build finishes." : "No log.")}
78 </pre>
79 </div>
80 );
81}