flagon-io/g1t

public

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

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

80 lines3,365 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";
8import { getViewer, roleIn } from "../../lib/session.server";
9
Social cards for every page: og.g1t.sh10export function meta({ params, ...args }: Route.MetaArgs) {
11 return page(args, { title: `Deployment · ${params.owner}/${params.repo} · g1t` });
Deployments: a preview for every pull request, production on g1t.page12}
13
14export async function loader({ params, context }: Route.LoaderArgs) {
15 const viewer = getViewer(context);
16 if (!roleIn(viewer, params.owner)) throw data(null, { status: 404 });
Projects: what a workspace builds and runs, first on every page17 const found = await deployments.get({ workspace: params.owner, slug: params.repo }, params.id, viewer);
Deployments: a preview for every pull request, production on g1t.page18 if (!found.ok) throw data(null, { status: 404 });
19 return { build: found.value };
20}
21
22const WORDS = {
23 queued: "Waiting for a sandbox",
24 building: "Building",
25 ready: "Live",
Builds say Replaced or Down once they are no longer live26 replaced: "Replaced by a newer build",
27 down: "Taken down",
Deployments: a preview for every pull request, production on g1t.page28 failed: "Failed",
29 skipped: "Skipped",
30} as const;
31
32export default function DeploymentPage({ loaderData, params }: Route.ComponentProps) {
33 const { build } = loaderData;
34 const base = `/${params.owner}/${params.repo}`;
35 return (
36 <div className="mx-auto max-w-5xl">
37 <Link to={`${base}/deployments`} className="inline-flex items-center gap-1 text-sm text-muted hover:text-fg">
38 <ArrowLeft size={14} />
39 Deployments
40 </Link>
41 <h1 className="mt-3 text-xl font-semibold tracking-tight">
42 {build.kind === "production" ? "Production" : (
43 <>
Projects: what a workspace builds and runs, first on every page44 Preview of <span className="font-mono">{build.branch}</span>
45 {build.number != null && (
46 <Link to={`${base}/pull/${build.number}`} className="ml-2 text-base font-normal text-muted hover:underline">
47 #{build.number}
48 </Link>
49 )}
Deployments: a preview for every pull request, production on g1t.page50 </>
51 )}
52 <span className="ml-3 font-mono text-sm font-normal text-faint">{build.commit.slice(0, 12)}</span>
53 </h1>
54 <p className="mt-1 text-sm text-muted">
55 {WORDS[build.status]} · started <TimeAgo at={build.createdAt} /> by {build.createdBy}
56 {build.buildSeconds != null && ` · built in ${build.buildSeconds} s`}
57 </p>
58 {build.status === "ready" && (
59 <a href={build.url} className="mt-3 inline-flex items-center gap-1.5 font-mono text-sm text-accent hover:underline">
60 {build.url.replace("https://", "")}
61 <ExternalLink size={12} />
62 </a>
63 )}
64 {build.error && (
65 <p className="mt-4 rounded-lg border border-danger/30 bg-danger/5 px-4 py-3 text-sm">{build.error}</p>
66 )}
67 {build.warnings.length > 0 && (
68 <ul className="mt-4 space-y-1 rounded-lg border border-warn/30 bg-warn/5 px-4 py-3 text-sm">
69 {build.warnings.map((warning) => (
70 <li key={warning}>{warning}</li>
71 ))}
72 </ul>
73 )}
74 <h2 className="mt-8 text-sm font-medium text-muted">Build log</h2>
75 <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">
76 {build.log || (build.status === "queued" || build.status === "building" ? "The log appears when the build finishes." : "No log.")}
77 </pre>
78 </div>
79 );
80}