my own status page
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: use second assign token

+31 -3
+26 -1
src/github.ts
··· 13 13 token: string, 14 14 owner: string, 15 15 repo: string, 16 - opts: { title: string; body: string; assignees?: string[]; labels?: string[] }, 16 + opts: { title: string; body: string; labels?: string[] }, 17 17 ): Promise<number> { 18 18 const res = await fetch(`https://api.github.com/repos/${owner}/${repo}/issues`, { 19 19 method: "POST", ··· 30 30 } 31 31 const data = await res.json<{ number: number }>(); 32 32 return data.number; 33 + } 34 + 35 + export async function assignIssue( 36 + token: string, 37 + owner: string, 38 + repo: string, 39 + issueNumber: number, 40 + assignees: string[], 41 + ): Promise<void> { 42 + const res = await fetch( 43 + `https://api.github.com/repos/${owner}/${repo}/issues/${issueNumber}/assignees`, 44 + { 45 + method: "POST", 46 + headers: { 47 + Authorization: `Bearer ${token}`, 48 + Accept: "application/vnd.github+json", 49 + "User-Agent": "infra-status-worker", 50 + }, 51 + body: JSON.stringify({ assignees }), 52 + }, 53 + ); 54 + if (!res.ok) { 55 + const text = await res.text(); 56 + throw new Error(`GitHub assign issue failed: ${res.status} ${text}`); 57 + } 33 58 } 34 59 35 60 export async function commentOnIssue(
+4 -2
src/index.ts
··· 9 9 import { handleBadgeRoute } from "./routes/badge"; 10 10 import { handleIndex } from "./routes/index"; 11 11 import { handleIncidentRoute } from "./routes/incidents"; 12 - import { createIssue, commentOnIssue, closeIssue, parseRepo, syncGitHubIncidents } from "./github"; 12 + import { createIssue, assignIssue, commentOnIssue, closeIssue, parseRepo, syncGitHubIncidents } from "./github"; 13 13 import { schemas } from "./schemas"; 14 14 15 15 async function handleRequest(request: Request, env: Env): Promise<Response> { ··· 128 128 const issueNumber = await createIssue(env.GITHUB_TOKEN, parsed.owner, parsed.repo, { 129 129 title: `${svc.name} is ${result.status}`, 130 130 body: `Automated incident detected by [infra.dunkirk.sh](https://infra.dunkirk.sh)\n\n**Service:** ${svc.name}\n**Health URL:** ${svc.health_url}\n**Status:** ${result.status}${result.status_code ? ` (HTTP ${result.status_code})` : ""}${result.error ? ` — ${result.error}` : ""}\n**Latency:** ${result.latency_ms}ms\n**Detected at:** ${new Date().toISOString()}\n\n---\n*Comments on this issue will appear on the status page. Close the issue to resolve the incident.*`, 131 - assignees: env.GITHUB_ASSIGNEE ? [env.GITHUB_ASSIGNEE] : [], 132 131 labels: ["incident"], 133 132 }); 133 + if (env.GITHUB_ASSIGN_TOKEN && env.GITHUB_ASSIGNEE) { 134 + await assignIssue(env.GITHUB_ASSIGN_TOKEN, parsed.owner, parsed.repo, issueNumber, [env.GITHUB_ASSIGNEE]); 135 + } 134 136 await setIncidentGitHub(env.DB, id, `${parsed.owner}/${parsed.repo}`, issueNumber); 135 137 } catch (_) {} // best effort 136 138 }
+1
src/types.ts
··· 65 65 TAILSCALE_API_KEY?: string; 66 66 TRIAGE_AUTH_TOKEN?: string; 67 67 GITHUB_TOKEN?: string; 68 + GITHUB_ASSIGN_TOKEN?: string; 68 69 GITHUB_ASSIGNEE?: string; 69 70 }