g1t/apps/web/app/routes/repo/actions-log.ts
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.
| GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs | 1 | import { data } from "react-router"; |
| 2 | ||
| 3 | import type { Route } from "./+types/actions-log"; | |
| 4 | import { actions } from "../../lib/services.server"; | |
| 5 | import { getViewer } from "../../lib/session.server"; | |
| 6 | ||
| 7 | /** A job's log after `?after=`, for the run page to fetch as it grows. */ | |
| 8 | export async function loader({ params, context, request }: Route.LoaderArgs) { | |
| 9 | const after = Number(new URL(request.url).searchParams.get("after") ?? 0); | |
| 10 | const log = await actions.logs( | |
| 11 | { namespace: params.owner, name: params.repo }, | |
| 12 | getViewer(context), | |
| 13 | params.job, | |
| 14 | Number.isFinite(after) && after > 0 ? after : 0, | |
| 15 | ); | |
| 16 | if (!log.ok) throw data({ error: log.error.message }, { status: log.error.code === "not_found" ? 404 : 400 }); | |
| 17 | return Response.json(log.value, { headers: { "cache-control": "no-store" } }); | |
| 18 | } |