name: 'Request reviews from code owners of a PR'
on:
  pull_request_target:
    types:
      - opened
      - synchronize
      - ready_for_review

permissions:
  contents: read

jobs:
  request_codeowners_review:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    if: ${{ github.repository_owner == 'open-telemetry' && github.event.pull_request.draft == false }}
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

      - name: Run request_codeowners_review.sh
        run: ./tools/request_codeowners_review.sh
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          REPO: ${{ github.repository }}
          PR: ${{ github.event.number }}
