name: "PR Labeler"
on:
  pull_request_target:
  workflow_dispatch:
    inputs:
      prs:
        required: false
        description: "pr number"

jobs:
  labeler:
    permissions:
      contents: read
      pull-requests: write
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: git config
        run: |
          git config user.name "${GITHUB_ACTOR}"
          git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
      - name: Set PR number
        id: set-pr
        run: |
            echo "Using PR number: ${{ github.event.inputs.prs || github.event.pull_request.number }}"
            echo "pr=${{ github.event.inputs.prs || github.event.pull_request.number }}" >> $GITHUB_OUTPUT

      - uses: actions/labeler@v5
        with:
           pr-number: ${{ steps.set-pr.outputs.pr }}
