fix: truncate body if exceeds max length (#1915)

This commit is contained in:
Peter Evans 2023-05-02 10:37:56 +09:00 committed by GitHub
parent 9e5b234402
commit 284f54f989
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

5
dist/index.js vendored
View file

@ -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

View file

@ -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)