name: 'Add labels and code owners to PR'
on:
  pull_request_target:
    types:
      - opened
      - synchronize
      - ready_for_review

permissions: read-all

jobs:
  add-labels-and-owners:
    permissions:
      pull-requests: write
    runs-on: ubuntu-24.04
    if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]' && github.repository_owner == 'open-telemetry' && github.event.pull_request.draft == false }}
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

      - name: Run add-codeowners-to-pr.sh
        run: ./.github/workflows/scripts/add-labels-and-owners.sh
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          REPO: ${{ github.repository }}
          PR: ${{ github.event.number }}
