Skip to content

Commit

Permalink
fix: trim comment if it's too long
Browse files Browse the repository at this point in the history
  • Loading branch information
Chriscbr committed Sep 24, 2024
1 parent 828c1b5 commit a9fb68f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion actions/pull-request-diff/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,18 @@ import {runCommand, stateFile} from './utils'
const postComment = async (output: string): Promise<void> => {
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.' : ''}
<details><summary>Show Plan</summary>
\`\`\`
Expand All @@ -20,7 +28,8 @@ ${output}
</details>
`
// 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!,
Expand Down

0 comments on commit a9fb68f

Please sign in to comment.