name: Autolabel

on:
  pull_request_target:
    types: [opened, edited, synchronize, closed, assigned, labeled, unlabeled]
  issues:
    types: [opened, edited, closed, assigned, labeled, unlabeled]
  issue_comment:
    types: [created]

jobs:
  pr_labeler:
    name: Labeler
    runs-on: utilities
    if: ${{ github.event.sender.login != 'ffmpeg-devel' }}
    steps:
      - name: Checkout
        uses: actions/checkout@v6
      - name: Label by file-changes
        uses: actions/labeler@v6
        if: ${{ forge.event_name == 'pull_request_target' }}
        with:
          configuration-path: .forgejo/labeler/labeler.yml
          repo-token: ${{ secrets.AUTOLABELER_TOKEN }}
      - name: Label by title-match
        uses: actions/github-script@v8
        with:
          script: |
            const script = require('.forgejo/labeler/labeler.js')
            await script({github, context})
          github-token: ${{ secrets.AUTOLABELER_TOKEN }}
