({
prId,
githubToken,
body,
}: CommentOnPRConfig)
| 270 | } |
| 271 | |
| 272 | export async function isDuplicateComment({ |
| 273 | prId, |
| 274 | githubToken, |
| 275 | body, |
| 276 | }: CommentOnPRConfig) { |
| 277 | const response = await fetchWithRetries( |
| 278 | `https://api.github.com/repos/cloudflare/templates/issues/${prId}/comments`, |
| 279 | { |
| 280 | headers: { |
| 281 | Authorization: `Bearer ${githubToken}`, |
| 282 | Connection: "close", |
| 283 | }, |
| 284 | }, |
| 285 | ); |
| 286 | if (!response.ok) { |
| 287 | throw new Error( |
| 288 | `Error response from GitHub (${response.status}): ${await response.text()}`, |
| 289 | ); |
| 290 | } |
| 291 | const comments = (await response.json()) as Array<{ body: string }>; |
| 292 | return comments.find((comment) => comment.body === body); |
| 293 | } |
| 294 | |
| 295 | export type PRState = "open" | "closed" | "all"; |
| 296 |
no test coverage detected