fix: truncate body when it exceeds the max length (#182)

This commit is contained in:
Peter Evans 2023-05-02 10:07:38 +09:00 committed by GitHub
parent 3518fea64b
commit ca08ebd5dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3526 additions and 1611 deletions

5
dist/index.js vendored
View File

@ -130,6 +130,11 @@ function appendSeparatorTo(body, separator) {
}
function createComment(octokit, owner, repo, issueNumber, body) {
return __awaiter(this, void 0, void 0, function* () {
// 65536 characters is the maximum allowed for issue comments.
if (body.length > 65536) {
core.warning(`Comment body is too long. Truncating to 65536 characters.`);
body = body.substring(0, 65536);
}
const { data: comment } = yield octokit.rest.issues.createComment({
owner: owner,
repo: repo,

5126
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -125,6 +125,12 @@ async function createComment(
issueNumber: number,
body: string
): Promise<number> {
// 65536 characters is the maximum allowed for issue comments.
if (body.length > 65536) {
core.warning(`Comment body is too long. Truncating to 65536 characters.`)
body = body.substring(0, 65536)
}
const {data: comment} = await octokit.rest.issues.createComment({
owner: owner,
repo: repo,