name: CI

on:
  pull_request:
    branches:
      - develop

jobs:
  changed_files:
    runs-on: ubuntu-latest 
    name: Check CHANGELOG.md
    steps:
      - uses: actions/checkout@v4
      - name: changelog modified
        id: changelog-modified
        uses: tj-actions/changed-files@v45
        with:
          files: CHANGELOG.md

      - name: List all changed files
        env:
          ALL_CHANGED_FILES: ${{ steps.changelog-modified.outputs.all_changed_files }}
        run: |
          if [[ ${ALL_CHANGED_FILES[*]} =~ (^|[[:space:]])"CHANGELOG.md"($|[[:space:]]) ]];
          then
            echo "CHANGELOG.md was modified.";
            exit 0;
          else
            echo "CHANGELOG.md was not modified.";
            echo "Please see CHANGELOG.md and follow the instructions to add your changes to that file."
            echo "In some rare scenarios, a changelog entry is not required and this CI check can be ignored."
            exit 1;
          fi
