Skip to content

g1t/apps/web/app/routes/repo/actions-artifact.ts

31 lines1,406 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.

Actions: OIDC tokens, the toolkit's cache and artifact services, and artifacts in R21import { redirect } from "react-router";
2
Actions: workflow_run, workflow.completed, artifacts on the run page, Node 243import type { Route } from "./+types/actions-artifact";
Actions: OIDC tokens, the toolkit's cache and artifact services, and artifacts in R24import { addresses } from "../../lib/addresses.server";
Actions: workflow_run, workflow.completed, artifacts on the run page, Node 245import { readArtifact } from "../../lib/artifacts.server";
6import { actions } from "../../lib/services.server";
7import { getViewer } from "../../lib/session.server";
8
Actions: OIDC tokens, the toolkit's cache and artifact services, and artifacts in R29/**
10 * One artifact of a run, for anyone who can see the run: a redirect to a
11 * link the API signed for a few minutes, or, for one an older runner kept
12 * in KV, its bytes.
13 */
Actions: workflow_run, workflow.completed, artifacts on the run page, Node 2414export async function loader({ params, context }: Route.LoaderArgs) {
Actions: OIDC tokens, the toolkit's cache and artifact services, and artifacts in R215 const repo = { namespace: params.owner, name: params.repo };
16 const viewer = getViewer(context);
17 const found = await actions.artifactDownload(repo, viewer, { run: params.id, name: params.name });
18 if (found.ok && found.value.blob) {
19 throw redirect(`${addresses().api}/actions/toolkit/blobs/${found.value.blob}`);
20 }
21 const seen = await actions.run(repo, viewer, params.id);
Actions: workflow_run, workflow.completed, artifacts on the run page, Node 2422 if (!seen.ok) throw new Response("Not found.", { status: 404 });
23 const bytes = await readArtifact(params.id, params.name);
Actions: OIDC tokens, the toolkit's cache and artifact services, and artifacts in R224 if (!bytes) throw new Response("That artifact is gone: it expired or was deleted.", { status: 404 });
Actions: workflow_run, workflow.completed, artifacts on the run page, Node 2425 return new Response(bytes.buffer as ArrayBuffer, {
26 headers: {
27 "content-type": "application/gzip",
28 "content-disposition": `attachment; filename="${params.name.replace(/"/g, "")}.tar.gz"`,
29 },
30 });
31}