name: Check PRs for merge conflicts

on:
  # Check for new conflicts due to merges.
  push:
    branches:
      - master
  # Check conflicts in new PRs and for resolved conflicts due to an open PR being updated.
  pull_request_target:
    types:
      - opened
      - edited
      - synchronize
      - reopened

# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
  # The concurrency group contains the workflow name and the branch name.
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  check-prs:
    runs-on: ubuntu-latest
    if: github.repository_owner == 'PHPCSStandards'

    name: Check PRs for merge conflicts

    steps:
      - uses: mschilde/auto-label-merge-conflicts@master
        with:
          CONFLICT_LABEL_NAME: "Status: has merge conflict"
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
