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

78 lines3,302 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",
26 failed: "Failed",
27 skipped: "Skipped",
28} as const;
29
30export default function DeploymentPage({ loaderData, params }: Route.ComponentProps) {
31 const { build } = loaderData;
32 const base = `/${params.owner}/${params.repo}`;
33 return (
34 <div className="mx-auto max-w-5xl">
35 <Link to={`${base}/deployments`} className="inline-flex items-center gap-1 text-sm text-muted hover:text-fg">
36 <ArrowLeft size={14} />
37 Deployments
38 </Link>
39 <h1 className="mt-3 text-xl font-semibold tracking-tight">
40 {build.kind === "production" ? "Production" : (
41 <>
Projects: what a workspace builds and runs, first on every page42 Preview of <span className="font-mono">{build.branch}</span>
43 {build.number != null && (
44 <Link to={`${base}/pull/${build.number}`} className="ml-2 text-base font-normal text-muted hover:underline">
45 #{build.number}
46 </Link>
47 )}
Deployments: a preview for every pull request, production on g1t.page48 </>
49 )}
50 <span className="ml-3 font-mono text-sm font-normal text-faint">{build.commit.slice(0, 12)}</span>
51 </h1>
52 <p className="mt-1 text-sm text-muted">
53 {WORDS[build.status]} · started <TimeAgo at={build.createdAt} /> by {build.createdBy}
54 {build.buildSeconds != null && ` · built in ${build.buildSeconds} s`}
55 </p>
56 {build.status === "ready" && (
57 <a href={build.url} className="mt-3 inline-flex items-center gap-1.5 font-mono text-sm text-accent hover:underline">
58 {build.url.replace("https://", "")}
59 <ExternalLink size={12} />
60 </a>
61 )}
62 {build.error && (
63 <p className="mt-4 rounded-lg border border-danger/30 bg-danger/5 px-4 py-3 text-sm">{build.error}</p>
64 )}
65 {build.warnings.length > 0 && (
66 <ul className="mt-4 space-y-1 rounded-lg border border-warn/30 bg-warn/5 px-4 py-3 text-sm">
67 {build.warnings.map((warning) => (
68 <li key={warning}>{warning}</li>
69 ))}
70 </ul>
71 )}
72 <h2 className="mt-8 text-sm font-medium text-muted">Build log</h2>
73 <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">
74 {build.log || (build.status === "queued" || build.status === "building" ? "The log appears when the build finishes." : "No log.")}
75 </pre>
76 </div>
77 );
78}