name: Changelog Check

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

jobs:
  check_change_log:
    runs-on: ubuntu-latest
    if: ${{!contains(github.event.pull_request.labels.*.name, 'NO-CHANGELOG-UPDATES')}}
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Ensure CHANGELOG.md is updated
        run: git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -wq "CHANGELOG.md"
