name: has_changelog
on:
  - pull_request

jobs:
  check_has_news_in_changelog_dir:
    if: |
      ! (
        contains(github.event.pull_request.labels.*.name, 'no-news-is-good-news') ||
        github.event.pull_request.user.login == 'pre-commit-ci[bot]' ||
        github.event.pull_request.user.login == 'dependabot[bot]'
      )
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:  # do a deep fetch to allow merge-base and diff
          fetch-depth: 0
      - name: check PR adds a news file
        run: |
          news_files="$(git diff --name-only "$(git merge-base origin/main "$GITHUB_SHA")" "$GITHUB_SHA" -- changelog.d/*.md)"
          if [ -n "$news_files" ]; then
            echo "Saw new files. changelog.d:"
            echo "$news_files"
          else
            echo "No news files seen"
            exit 1
          fi

name: has_changelog
on:
  pull_request:
    types:
      - labeled
      - unlabeled
      - opened
      - reopened
      - synchronize

jobs:
  check_has_news_in_changelog_dir:
    if: |
      ! (
        contains(github.event.pull_request.labels.*.name, 'no-news-is-good-news') ||
        github.event.pull_request.user.login == 'pre-commit-ci[bot]' ||
        github.event.pull_request.user.login == 'dependabot[bot]'
      )
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:  # do a deep fetch to allow merge-base and diff
          fetch-depth: 0
      - name: check PR adds a news file
        run: |
          news_files="$(git diff --name-only "$(git merge-base origin/main "$GITHUB_SHA")" "$GITHUB_SHA" -- changelog.d/*.md)"
          if [ -n "$news_files" ]; then
            echo "Saw new files. changelog.d:"
            echo "$news_files"
          else
            echo "No news files seen"
            exit 1
          fi

Expand CI changelog checker to run on label events
Expand CI changelog checker to run on label events

PR labeled,unlabeled events now trigger the workflow (other listed
event types are the defaults).
