From a9fb68f5daa450faf0838ae6f1197acbf3e1d2aa Mon Sep 17 00:00:00 2001 From: Chris Rybicki Date: Tue, 24 Sep 2024 16:33:39 -0400 Subject: [PATCH] fix: trim comment if it's too long --- actions/pull-request-diff/src/main.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/actions/pull-request-diff/src/main.ts b/actions/pull-request-diff/src/main.ts index 9a9242d..a1fa752 100644 --- a/actions/pull-request-diff/src/main.ts +++ b/actions/pull-request-diff/src/main.ts @@ -8,10 +8,18 @@ import {runCommand, stateFile} from './utils' const postComment = async (output: string): Promise => { const githubToken = core.getInput('github-token') const octokit = github.getOctokit(githubToken) + let trimmed = false + + if (output.length > 65000) { + output = output.slice(0, 65000) + trimmed = true + } const githubContext = github.context const comment = `#### Terraform Plan +${trimmed ? 'Plan is too large to display in a comment. Check the build logs for the full plan.' : ''} +
Show Plan \`\`\` @@ -20,7 +28,8 @@ ${output}
` - // creat a comment on the PR + + // create a comment on the PR await octokit.rest.issues.createComment({ ...githubContext.repo, issue_number: githubContext.payload.pull_request?.number!,