-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add workflow that comments changelog preview on PRs
- Loading branch information
1 parent
9cb5c20
commit 77580d8
Showing
3 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#! /bin/bash | ||
|
||
set -euo pipefail | ||
|
||
if [ $# -eq 0 ]; then | ||
echo "No arguments supplied. Use with '--token=<github token> --target-branch=<branch>'" | ||
exit 1 | ||
fi | ||
|
||
dry_run_output=$(npm run --silent release-please-dry-run -- "$@") | ||
|
||
echo "$dry_run_output" | grep --silent "Would open 1 pull request" || exit 0 | ||
|
||
echo "$dry_run_output" | sed -n '/---/,/---/p' | sed '1d;$d' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Changelog Preview | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
previewChangelog: | ||
name: Preview Changelog | ||
runs-on: ubuntu-latest | ||
# if: ${{ !github.event.pull_request.draft }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
|
||
- uses: actions/cache@v4 | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }} | ||
|
||
- name: Install npm packages | ||
run: npm ci | ||
|
||
- name: Generate Changelog Preview | ||
id: changelog-preview | ||
run: | | ||
changelog=$(npm run --silent release-please-changelog-preview -- --token=${{ secrets.GITHUB_TOKEN }} --target-branch=${{ github.head_ref || github.ref_name }}) | ||
echo "changelog<<EOF | ||
$changelog | ||
EOF" >> "$GITHUB_OUTPUT" | ||
- name: Comment on PR | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
if: ${{ steps.changelog-preview.outputs.changelog != '' }} | ||
with: | ||
skip_unchanged: true | ||
message: | | ||
This is a preview of the changelog of the next release: | ||
${{ steps.changelog-preview.outputs.changelog }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters