A GitHub Action that uses ChatGPT to summarize commit messages and generate changelogs for pull requests (PRs).
-
Summarizes individual commits in a PR and posts them as a comment.
-
Generates an overall summary and updates a changelog file (e.g.,
CHANGELOG.md
) when the PR is merged. -
Includes commit hashes for tracking in summaries.
-
Open-source and reusable by anyone with a ChatGPT API key.
-
An OpenAI API key (get one from OpenAI).
-
A GitHub repository where you want to use this action.
To integrate changelog-summarizer
into your GitHub repository, follow these steps:
Add the following workflows to your repository in the .github/workflows/
directory.
This workflow runs when a PR is opened or updated, summarizing commits and posting them as a PR comment.
.github/workflows/summarize-commits.yml
:
name: Summarize Commits
on:
pull_request:
types: [opened, synchronize]
permissions:
pull-requests: write
contents: read
jobs:
summarize:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: nsnguyen/changelog-summarizer@v1
with:
mode: summarize_commits
api-key: ${{ secrets.CHATGPT_API_KEY }}
github-token: ${{ github.token }}
This workflow runs when a PR is merged, generating an overall summary and updating CHANGELOG.md.
.github/workflows/update-changelog.yml
:
name: Update Changelog
on:
pull_request:
types: [closed]
permissions:
pull-requests: read
contents: write
jobs:
update:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.base.ref }}
- uses: nsnguyen/changelog-summarizer@v1
with:
mode: generate_changelog
api-key: ${{ secrets.CHATGPT_API_KEY }}
github-token: ${{ github.token }}
changelog-file: CHANGELOG.md
-
Go to your repository on GitHub > Settings > Secrets and variables > Actions > New repository secret.
-
Add a secret named
CHATGPT_API_KEY
with your OpenAI API key value. -
Ensure the API key has sufficient quota for ChatGPT API calls.
-
Change the Changelog File: Modify the
changelog-file
input inupdate-changelog.yml
to use a different file path (e.g.,docs/CHANGELOG.md
). -
Adjust Summary Format: If you want to customize how summaries are generated, fork this repository, modify
src/index.js
(e.g., change the ChatGPT prompt), rebuild withnpm run build
, and tag a new version (e.g.,v2
).
To keep your repository up-to-date with new versions of changelog-summarizer:
-
Check the Releases page for new versions (e.g.,
v2
,v3
). -
Update the version in your workflows by changing nsnguyen/changelog-summarizer@v1 to the latest version (e.g.,
nsnguyen/changelog-summarizer@v2
). -
Test the updated workflows in a PR to ensure compatibility with your repository.
### Commit Summaries
<!-- COMMIT_SUMMARIES_START -->
- This commit adds a final test Python file to the project. (Commit: abc123def)
- This commit improves the final test Python file. (Commit: xyz789ghi)
<!-- COMMIT_SUMMARIES_END -->
_Automatically updated by changelog-summarizer._
# Changelog
## [2025-02-20] PR #3: Add and improve final test Python file
- Enhanced the project with a final test Python file and improvements
-
This action uses ChatGPT API calls, which may incur costs based on usage (see OpenAI pricing).
-
Ensure your GITHUB_TOKEN has the necessary permissions (pull-requests: write, contents: read/write) as specified in the workflows.
-
The action requires Node.js 16 or later (bundled in GitHub Actions runners).