( owner: string, repo: string, issueNumber: number, duplicates: DuplicateMatch[], githubToken: string )
| 474 | * Post duplicate comment to issue |
| 475 | */ |
| 476 | export async function postDuplicateComment( |
| 477 | owner: string, |
| 478 | repo: string, |
| 479 | issueNumber: number, |
| 480 | duplicates: DuplicateMatch[], |
| 481 | githubToken: string |
| 482 | ): Promise<boolean> { |
| 483 | if (duplicates.length === 0) { |
| 484 | return false; |
| 485 | } |
| 486 | |
| 487 | try { |
| 488 | const client = new Octokit({ auth: githubToken }); |
| 489 | const comment = generateDuplicateComment(duplicates); |
| 490 | |
| 491 | console.log(`Posting duplicate comment to issue #${issueNumber}`); |
| 492 | |
| 493 | await retryWithBackoff(async () => { |
| 494 | await client.issues.createComment({ |
| 495 | owner, |
| 496 | repo, |
| 497 | issue_number: issueNumber, |
| 498 | body: comment, |
| 499 | }); |
| 500 | }); |
| 501 | |
| 502 | console.log(`Successfully posted duplicate comment to issue #${issueNumber}`); |
| 503 | return true; |
| 504 | } catch (error) { |
| 505 | console.error( |
| 506 | `Error posting duplicate comment to issue #${issueNumber}:`, |
| 507 | error |
| 508 | ); |
| 509 | return false; |
| 510 | } |
| 511 | } |
no test coverage detected