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/actions-artifact.ts

18 lines919 bytesCodeBlame
1import type { Route } from "./+types/actions-artifact";
2import { readArtifact } from "../../lib/artifacts.server";
3import { actions } from "../../lib/services.server";
4import { getViewer } from "../../lib/session.server";
5
6/** One artifact of a run, for anyone who can see the run. */
7export async function loader({ params, context }: Route.LoaderArgs) {
8 const seen = await actions.run({ namespace: params.owner, name: params.repo }, getViewer(context), params.id);
9 if (!seen.ok) throw new Response("Not found.", { status: 404 });
10 const bytes = await readArtifact(params.id, params.name);
11 if (!bytes) throw new Response("That artifact is gone: they are kept for 14 days.", { status: 404 });
12 return new Response(bytes.buffer as ArrayBuffer, {
13 headers: {
14 "content-type": "application/gzip",
15 "content-disposition": `attachment; filename="${params.name.replace(/"/g, "")}.tar.gz"`,
16 },
17 });
18}