name: Labeler
permissions:
  issues: write
  pull-requests: write
on:
  pull_request_target:
    types: ['edited', 'opened', 'reopened', 'synchronize']
  issues:
    types: ['opened', 'reopened']

jobs:
  labeler:
    name: Labeler
    runs-on: ubuntu-latest
    if: github.event_name == 'pull_request_target'
    steps:
      - uses: fuxingloh/multi-labeler@v4
        with:
          github-token: ${{secrets.GITHUB_TOKEN}}

  w_unverified_labeler:
    name: Add w-unverified Label
    if: ${{ !(github.event_name == 'pull_request_target' && (github.event.action == 'edited' || github.event.action == 'synchronize' )) && !(github.event_name == 'issues' && contains(github.event.issue.labels.*.name, 'api-docs-commits')) && github.actor != 'dependabot[bot]'}}
    runs-on: ubuntu-latest
    steps:
      - run: gh issue edit "$NUMBER" --add-label "$LABELS"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GH_REPO: ${{ github.repository }}
          NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
          LABELS: w-unverified
