Skip to content

Commit

Permalink
CI: add changelog check (#2766)
Browse files Browse the repository at this point in the history
* Added changelog item check

Fetch the base branch and diff correctly

- See: actions/checkout#160

Improve organisation

Add some echo for easier debugging

Fix bad variable syntax

Clarify the double-print in the success case

* Write to changelog

* Don't block dependabot PRs
  • Loading branch information
cyqsimon authored Nov 3, 2023
1 parent 1296aea commit bcc2de8
Show file tree
Hide file tree
Showing 2 changed files with 27 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
# dependabot PRs are automerged if CI passes; we shouldn't block these
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 "#${PR_NUMBER}\\b.*@${PR_SUBMITTER}\\b" <<< "$ADDED"
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

- Upgrade to Rust 2021 edition #2748 (@cyqsimon)
- Refactor and cleanup build script #2756 (@cyqsimon)
- Checks changelog has been written to for PRs in CI #2766 (@cyqsimon)

## Syntaxes

Expand Down

0 comments on commit bcc2de8

Please sign in to comment.