From 64dd23e0c8f92632ac72fbbd564f1cd08a39d448 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 23 Jul 2024 14:37:12 -0700 Subject: [PATCH] Truncate issue comments --- src/utils/gitUtils.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/utils/gitUtils.ts b/src/utils/gitUtils.ts index 1f12381..02ad4b1 100644 --- a/src/utils/gitUtils.ts +++ b/src/utils/gitUtils.ts @@ -137,8 +137,16 @@ export async function createIssue(postResult: boolean, title: string, bodyChunks const issueNumber = created.data.number; console.log(`Created issue #${issueNumber}: ${created.data.html_url}`); + const maxCommentLength = 65535; + const tooLongFooter = `\n\nThis comment was too long to display in full; see the build artifact for the full details.`; + for (const comment of additionalComments) { - await kit.issues.createComment({ issue_number: issueNumber, ...comment }); + let body = comment.body; + if (body.length > maxCommentLength) { + body = body.slice(0, maxCommentLength - tooLongFooter.length) + tooLongFooter; + } + + await kit.issues.createComment({ issue_number: issueNumber, ...comment, body }); } if (!sawNewErrors) {