import { env } from "cloudflare:workers"; import { mirrorFlagKey, mirrorStub } from "./mirror-do"; /** Called for every push into a forge repo; only repos with an enabled mirror reach their Durable Object. */ export async function notifyMirrorOfPush(repoId: string, ref: string, after: string): Promise<"queued" | "skipped"> { if (!(await env.KV.get(mirrorFlagKey(repoId)))) return "skipped"; try { await mirrorStub(repoId).notifyPush(ref, after); return "queued"; } catch (error) { console.warn("mirror push notify failed", repoId, error); return "skipped"; } }