Skip to content

build: add action to automatically merge changelog.json on release PRs#8234

Open
feywind wants to merge 8 commits intomainfrom
feywind-autoupdate-changelog
Open

build: add action to automatically merge changelog.json on release PRs#8234
feywind wants to merge 8 commits intomainfrom
feywind-autoupdate-changelog

Conversation

@feywind
Copy link
Copy Markdown
Contributor

@feywind feywind commented May 6, 2026

Many release PRs for handwritten/core created at once will result in the changelog.json file having conflicts in a way that's very difficult to merge through the GitHub UI. This adds an action workflow that does it for us.

@feywind feywind requested a review from a team as a code owner May 6, 2026 22:16
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a merge-changelog.cjs script and associated tests to automate the merging of changelog.json entries from pull requests. The script handles pull_request, push, and workflow_dispatch events. Review feedback identifies potential issues with GitHub API pagination in listFiles and pulls.list calls, recommending the use of github.paginate to ensure all files and pull requests are processed. It also suggests adding a trailing newline to the updated changelog.json for POSIX compliance.

Comment on lines +68 to +73
const response = await github.rest.pulls.listFiles({
owner,
repo,
pull_number: prNumber,
});
files = response.data;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The pulls.listFiles method is paginated and returns a limited number of files (default 30, max 100). If a pull request modifies many files, changelog.json might be missed if it's not in the first page of results. Using github.paginate ensures all files are checked.

    files = await github.paginate(github.rest.pulls.listFiles, {
      owner,
      repo,
      pull_number: prNumber,
    });


// Merge the changelogs
const mergedChangelog = mergeChangelogs(mainChangelog, prChangelog);
const newContent = JSON.stringify(mergedChangelog, null, 2);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It is a best practice for text files, including JSON, to end with a trailing newline. This prevents diff noise and adheres to POSIX standards. Since JSON.stringify does not include one, you should append it manually. This also ensures consistency if the original file already had a newline.

  const newContent = JSON.stringify(mergedChangelog, null, 2) + '\n';

Comment on lines +175 to +180
const response = await github.rest.pulls.list({
owner,
repo,
state: 'open',
});
pulls = response.data;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The pulls.list method is paginated (default 30 items). If the repository has many open pull requests, some might be skipped during a push or workflow_dispatch event. Using github.paginate ensures all open PRs are processed.

      pulls = await github.paginate(github.rest.pulls.list, {
        owner,
        repo,
        state: 'open',
      });

@feywind feywind added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge Indicates a pull request not ready for merge, due to either quality or timing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant