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