Skip to content

Add to changelog from github action #11253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2025
Merged

Add to changelog from github action #11253

merged 1 commit into from
Jul 26, 2025

Conversation

bhollis
Copy link
Contributor

@bhollis bhollis commented Jul 24, 2025

I asked Claude to build an action that would look for lines starting with "Changelog:" in commit messages (which are also populated by PR descriptions) and automatically add them to CHANGELOG.md. This avoids the changelog-merge problem GitHub has refused to fix for years.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces an automated changelog management system that extracts changelog entries from commit messages and updates the CHANGELOG.md file via GitHub Actions. This addresses the common merge conflict issues that occur when multiple contributors manually edit changelog files.

  • Automated extraction of changelog entries from commit messages containing "Changelog:" prefix
  • GitHub Action workflow that runs on pushes to master and automatically updates CHANGELOG.md
  • Test script for validating the changelog update functionality

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
build/update-changelog.js Core script that parses commits and updates the changelog file
build/test-changelog.js Test script for validating changelog update logic
.github/workflows/changelog-updater.yml GitHub Actions workflow for automated changelog updates
.github/pull_request_template.md Template reminder about changelog format

const trimmedLine = line.trim();
if (trimmedLine.toLowerCase().startsWith('changelog:')) {
// Extract text after "Changelog:" and trim whitespace
const changelogText = trimmedLine.substring(10).trim();
Copy link
Preview

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

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

The magic number 10 represents the length of 'changelog:'. Consider using a constant like const CHANGELOG_PREFIX = 'changelog:' and then use CHANGELOG_PREFIX.length for better maintainability.

Suggested change
const changelogText = trimmedLine.substring(10).trim();
const changelogText = trimmedLine.substring(CHANGELOG_PREFIX.length).trim();

Copilot uses AI. Check for mistakes.

});

console.log('\nTest setup complete. You can now run:');
console.log(" echo './commits.json' | node build/update-changelog.js");
Copy link
Preview

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

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

The command echo './commits.json' would output the string './commits.json', not the file contents. This should be cat commits.json to actually pipe the file contents.

Suggested change
console.log(" echo './commits.json' | node build/update-changelog.js");
console.log(" cat commits.json | node build/update-changelog.js");

Copilot uses AI. Check for mistakes.

- name: Update changelog from commits
id: changelog
run: |
echo '${{ toJson(github.event.commits) }}' | node build/update-changelog.js > docs/CHANGELOG.md.new
Copy link
Preview

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

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

Using toJson() directly in shell command could be vulnerable to command injection if commit messages contain shell metacharacters. Consider writing the JSON to a temporary file first, then piping that file to the script.

Suggested change
echo '${{ toJson(github.event.commits) }}' | node build/update-changelog.js > docs/CHANGELOG.md.new
echo '${{ toJson(github.event.commits) }}' > commits.json
node build/update-changelog.js commits.json > docs/CHANGELOG.md.new
rm commits.json

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@delphiactual delphiactual left a comment

Choose a reason for hiding this comment

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

should we also mark CHANGELOG.md as read-only?

@bhollis
Copy link
Contributor Author

bhollis commented Jul 24, 2025

No, it's fine to still edit it directly

@bhollis bhollis merged commit baf024d into master Jul 26, 2025
6 checks passed
@bhollis bhollis deleted the auto-changelog branch July 26, 2025 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants