Skip to content

Commit

Permalink
fix: truncate body if exceeds max length (#1915)
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-evans authored May 2, 2023
1 parent 9e5b234 commit 284f54f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@ function createPullRequest(inputs) {
// Update the body input with the contents of the file
inputs.body = utils.readFile(inputs.bodyPath);
}
// 65536 characters is the maximum allowed for the pull request body.
if (inputs.body.length > 65536) {
core.warning(`Pull request body is too long. Truncating to 65536 characters.`);
inputs.body = inputs.body.substring(0, 65536);
}
// Get the repository path
const repoPath = utils.getRepoPath(inputs.path);
// Create a git command manager
Expand Down
7 changes: 7 additions & 0 deletions src/create-pull-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
// Update the body input with the contents of the file
inputs.body = utils.readFile(inputs.bodyPath)
}
// 65536 characters is the maximum allowed for the pull request body.
if (inputs.body.length > 65536) {
core.warning(
`Pull request body is too long. Truncating to 65536 characters.`
)
inputs.body = inputs.body.substring(0, 65536)
}

// Get the repository path
const repoPath = utils.getRepoPath(inputs.path)
Expand Down

0 comments on commit 284f54f

Please sign in to comment.