name: PR to master

on:
  pull_request:
    branches:
      - master
    # Only following types are handled by the action, but one can default to all as well
    types: [opened, reopened, edited, synchronize]

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true


jobs:

  # Refs: https://github.com/release-drafter/release-drafter
  auto-labeling:
    runs-on: ubuntu-latest

    if: |
      !contains(github.event.pull_request.labels.*.name, 'exclude from changelog')

    steps:
      - uses: release-drafter/release-drafter@v5
        with:
          disable-releaser: true
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  check-title:
    runs-on: ubuntu-latest

    if: |
      (!contains( github.event.pull_request.labels.*.name, 'exclude from changelog' ) &&
        !startsWith( github.head_ref, 'dependabot/' ))

    steps:
      - uses: amannn/action-semantic-pull-request@v4.2.0
        with:
          types: |
            feat
            imprv
            fix
            support
            chore
            ci
            docs
            test
          requireScope: false
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
