Skip to content

Commit

Permalink
Limit length of PR body to GH maximum (again) (#96)
Browse files Browse the repository at this point in the history
Attempt num 2 since the first time didn't work: #92

CI in apps-monorepo is failing bc the PR body's we generate exceed GH's limit.
  • Loading branch information
sergeichestakov authored Jun 21, 2024
1 parent b8cda0f commit 5c8d28c
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions packages/action/src/util/get-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ const capitalise = (str: string) =>

// GitHub enforces a max length of 65536 characters for a pull request body
const maxLength = 65536;
const lengthBuffer = 1000;

export const makeGithubReleaseMessage = (stats: ReleaseStats) =>
`
export const makeGithubReleaseMessage = (stats: ReleaseStats) => {
const message = `
${Object.entries(stats.pulls)
.map(
([key, pulls]) => `
Expand All @@ -25,9 +26,17 @@ ${pulls.map(({ title }) => `- ${title}`).join('\n')}
${Array.from(stats.authors)
.map((author) => `@${author}`)
.join(', ')}
`
.trim()
.slice(0, maxLength);
`.trim();

if (message.length >= maxLength - lengthBuffer) {
return `${message.slice(
0,
maxLength - lengthBuffer,
)}...\nThis message has been truncated to avoid exceeding the GitHub API's body limit.`;
}

return message;
};

const getReleaseMessage = async (prerelease: boolean) => {
const latestRelease = await getLatestRelease(prerelease);
Expand Down

0 comments on commit 5c8d28c

Please sign in to comment.