mirror of
https://github.com/peter-evans/create-or-update-comment.git
synced 2025-01-19 03:26:42 +08:00
Update distribution (#210)
Co-authored-by: peter-evans <peter-evans@users.noreply.github.com>
This commit is contained in:
parent
ce3fa353c4
commit
c6c9a1a660
16
dist/index.js
vendored
16
dist/index.js
vendored
@ -128,13 +128,17 @@ function appendSeparatorTo(body, separator) {
|
|||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function truncateBody(body) {
|
||||||
|
// 65536 characters is the maximum allowed for issue comments.
|
||||||
|
if (body.length > 65536) {
|
||||||
|
core.warning(`Comment body is too long. Truncating to 65536 characters.`);
|
||||||
|
return body.substring(0, 65536);
|
||||||
|
}
|
||||||
|
return body;
|
||||||
|
}
|
||||||
function createComment(octokit, owner, repo, issueNumber, body) {
|
function createComment(octokit, owner, repo, issueNumber, body) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// 65536 characters is the maximum allowed for issue comments.
|
body = truncateBody(body);
|
||||||
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({
|
const { data: comment } = yield octokit.rest.issues.createComment({
|
||||||
owner: owner,
|
owner: owner,
|
||||||
repo: repo,
|
repo: repo,
|
||||||
@ -158,7 +162,7 @@ function updateComment(octokit, owner, repo, commentId, body, editMode, appendSe
|
|||||||
});
|
});
|
||||||
commentBody = appendSeparatorTo(comment.body ? comment.body : '', appendSeparator);
|
commentBody = appendSeparatorTo(comment.body ? comment.body : '', appendSeparator);
|
||||||
}
|
}
|
||||||
commentBody = commentBody + body;
|
commentBody = truncateBody(commentBody + body);
|
||||||
core.debug(`Comment body: ${commentBody}`);
|
core.debug(`Comment body: ${commentBody}`);
|
||||||
yield octokit.rest.issues.updateComment({
|
yield octokit.rest.issues.updateComment({
|
||||||
owner: owner,
|
owner: owner,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user