name: Changelog check

on:
  pull_request:
    branches: [main]

jobs:
  changelog:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Check CHANGELOG.md was updated
        run: |
          if git diff --name-only origin/main...HEAD | grep -q '^CHANGELOG.md$'; then
            echo "CHANGELOG.md was updated."
          else
            echo "::error::CHANGELOG.md was not updated. Please add an entry under [Unreleased]."
            exit 1
          fi
