Skip to content

Commit

Permalink
CI: ensure a changelog entry exists for each PR (#331)
Browse files Browse the repository at this point in the history
* CI: ensure a changelog entry exists for each PR

* Write CHANGELOG

* Fix grep by adding `-P`
  • Loading branch information
cyqsimon authored Nov 12, 2023
1 parent 16a6f9e commit 2382706
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/require-changelog-for-PRs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Changelog

on:
pull_request:

jobs:
check-changelog:
name: Check for changelog entry
runs-on: ubuntu-latest
# allow dependabot PRs to have no changelog
if: github.actor != 'dependabot[bot]'
env:
PR_SUBMITTER: ${{ github.actor }}
PR_NUMBER: ${{ github.event.number }}
PR_BASE: ${{ github.base_ref }}
steps:
- uses: actions/checkout@v4
- name: Fetch PR base
run: git fetch --no-tags --prune --depth=1 origin
- name: Search for added line in changelog
run: |
ADDED=$(git diff -U0 "origin/${PR_BASE}" HEAD -- CHANGELOG.md | grep -P '^\+[^\+].+$')
echo "Added lines in CHANGELOG.md:"
echo "$ADDED"
echo "Grepping for PR info:"
grep -P "(#|pull/)${PR_NUMBER}\\b.*@${PR_SUBMITTER}\\b" <<< "$ADDED"
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [Unreleased]

### Added

* CI: ensure a changelog entry exists for each PR #331 - @cyqsimon

## [0.21.1] - 2023-10-16

### Fixed
Expand Down

0 comments on commit 2382706

Please sign in to comment.