Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/verify-changelog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This action requires that any PR targeting the main branch should touch at
# least one CHANGELOG file. If a CHANGELOG entry is not required, add the
# "Skip Changelog" label, the "dependencies" label, or include "[chore]" in
# the PR title.

name: Verify CHANGELOG

on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
branches:
- main

permissions: read-all

jobs:
changelog:
runs-on: ubuntu-latest

# Skip if:
# - PR has "Skip Changelog" label
# - PR has "dependencies" label
# - PR title contains "[chore]"
if: >
! contains(github.event.pull_request.labels.*.name, 'Skip Changelog') &&
! contains(github.event.pull_request.labels.*.name, 'dependencies') &&
! contains(github.event.pull_request.title, '[chore]')

steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0

- name: Verify CHANGELOG updated
run: |
echo "Fetching base branch..."
git fetch origin ${{ github.base_ref }} --depth=1

echo "Checking for CHANGELOG modifications..."
if git diff --name-only FETCH_HEAD | grep -q 'CHANGELOG'; then
Comment on lines +37 to +41
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fixes a subtle bug in the workflow, which is that once a new commit is merged to main (which updates the CHANGELOG.md), the diff with ${{ github.base_ref }} will think the CHANGELOG.md has been updated (this is what using --merge-base fixes)

(also I inlined FETCH_HEAD since the extra fetch isn't needed due to using fetch-depth: 0 above)

Suggested change
echo "Fetching base branch..."
git fetch origin ${{ github.base_ref }} --depth=1
echo "Checking for CHANGELOG modifications..."
if git diff --name-only FETCH_HEAD | grep -q 'CHANGELOG'; then
echo "Checking for CHANGELOG modifications..."
if git diff --name-only --merge-base origin/${{ github.base_ref }} | grep -q 'CHANGELOG'; then

echo "CHANGELOG updated — OK"
else
echo "::error::No CHANGELOG file was updated in this PR."
echo "Please update CHANGELOG or use the 'Skip Changelog' label if appropriate."
false
fi
Loading