https://github.com/ext/pull-request-changelog
Generate changelog from conventional changelog for using in a pull request comment
https://github.com/ext/pull-request-changelog
Last synced: 4 months ago
JSON representation
Generate changelog from conventional changelog for using in a pull request comment
- Host: GitHub
- URL: https://github.com/ext/pull-request-changelog
- Owner: ext
- License: mit
- Created: 2025-04-09T16:31:26.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-09T22:31:30.000Z (about 1 year ago)
- Last Synced: 2025-04-09T22:36:55.304Z (about 1 year ago)
- Language: TypeScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# pull-request-changelog
Add a sticky comment to a pull request with the changelog entries for the new commits.
Features:
- [Github action](https://github.com/marketplace/actions/pull-requst-changelog) for easy integration with Github.
- CLI and API for custom usage.
- Supports both Conventional Changelog presets or a custom configuration.
- Works with Semantic Release

## Usage with Github Actions (recommended)
Create a workflow with these steps:
```yaml
on:
pull_request:
permissions:
pull-requests: write
jobs:
pr-changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: "${{ github.head_ref }}"
- uses: actions/setup-node@v4
with:
node-version: 22.x
- run: npm ci
- name: Pull Requst Changelog
uses: ext/pull-request-changelog@v1
with:
preset: conventional-changelog-conventionalcommits
```
> [!NOTE]
> Node 22.x or later is required, make sure to specify `node-version`!
If you want to only run for pull requests targeting certain branches add:
```diff
on:
pull_request:
+ branches:
+ - main
```
### Configuration
The following input parameters are provided, which can be passed to the `with` parameter.
All parameters are optional.
Input parameter | Default | Description
--- | --- | ---
preset | | full name of an NPM package with a conventional changelog preset
config | | path to a configuration file exporting a configuration
template-dir | | directory with templates
filename | "pr-changelog.md" | name of temporary file generated by script
comment | true | If `true` a sticky comment will be added with the changelog.
comment-id | "pull-request-changelog" | id passed to sticky-pull-request-commend
fetch-depth | 100 | git commit depth
version | "auto" | NPM script version (passed to npx). Default is to use same script version as action version.
skip-install | | Skip installing NPM package (you need to manually ensure the package exists)
## Usage with CLI
```bash
npx pull-request-changelog \
--preset conventional-changelog-conventionalcommits \
--from origin/main \
--to HEAD
```
Do note that the full name of the preset must be specified, this is different to how `conventional-changelog-cli` handles `-p`.
```plaintext
Generate changelog from conventional changelog for using in a pull request comment.
Usage
$ npx pull-request-changelog -f origin/main
Options
--from, -f Base branch/ref
--to, -t Pull request branch/ref (default: HEAD)
--preset, -p Conventional Changelog preset (NPM package)
--config, -c Conventional Changelog config (filename)
--output, -o Output file (default stdout)
--template-dir, -T Template directory
Other
--help Show usage
--version Show version
The template directory may contain the files:
- message.hbs for the main template
- header.hbs for the header partial
- footer.hbs for the footer partial
```
If you need to customize the configuration for the conventional-changelog preset create a new file default exporting a function wrapping the preset and use `--config` instead:
```ts
import conventionalChangelogConventionalcommits from "conventionallchangelog-conventionalcommits";
export default () => {
return conventionalChangelogConventionalcommits({
/* preset configuration */
});
};
```
```diff
npx pull-request-changelog \
- --preset conventional-changelog-conventionalcommits \
+ --config my-config.mjs \
--from origin/main \
--to HEAD
```
## Usage with API
```ts
import { pullRequestChangelog } from "pull-request-changelog";
import conventionalChangelogConventionalcommits from "conventionallchangelog-conventionalcommits";
const markdown = await pullRequestChangelog({
config: conventionalChangelogConventionalcommits({
/* preset configuration */
}),
git: {
from: "origin/main",
to: "HEAD",
},
});
```