File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,18 +118,23 @@ function appendSeparatorTo(body: string, separator: string): string {
118118 }
119119}
120120
121+ function truncateBody ( body : string ) {
122+ // 65536 characters is the maximum allowed for issue comments.
123+ if ( body . length > 65536 ) {
124+ core . warning ( `Comment body is too long. Truncating to 65536 characters.` )
125+ return body . substring ( 0 , 65536 )
126+ }
127+ return body
128+ }
129+
121130async function createComment (
122131 octokit ,
123132 owner : string ,
124133 repo : string ,
125134 issueNumber : number ,
126135 body : string
127136) : Promise < number > {
128- // 65536 characters is the maximum allowed for issue comments.
129- if ( body . length > 65536 ) {
130- core . warning ( `Comment body is too long. Truncating to 65536 characters.` )
131- body = body . substring ( 0 , 65536 )
132- }
137+ body = truncateBody ( body )
133138
134139 const { data : comment } = await octokit . rest . issues . createComment ( {
135140 owner : owner ,
@@ -164,7 +169,7 @@ async function updateComment(
164169 appendSeparator
165170 )
166171 }
167- commentBody = commentBody + body
172+ commentBody = truncateBody ( commentBody + body )
168173 core . debug ( `Comment body: ${ commentBody } ` )
169174 await octokit . rest . issues . updateComment ( {
170175 owner : owner ,
You can’t perform that action at this time.
0 commit comments