name: "Pull Request Labeler"
on:
  pull_request:
    types: [opened, reopened]

permissions:
  id-token: none

jobs:
  triage:
    runs-on: ubuntu-22.04
    steps:
      - name: Label based on changed files
        uses: actions/labeler@v5
        with:
          repo-token: "${{ secrets.PYVISTA_BOT_TOKEN }}"

      # Label based on branch name
      - uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf
        if: startsWith(github.event.pull_request.head.ref, 'doc/') || startsWith(github.event.pull_request.head.ref, 'docs')
        with:
          github_token: "${{ secrets.PYVISTA_BOT_TOKEN }}"
          labels: documentation
      - uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf
        if: startsWith(github.event.pull_request.head.ref, 'docker')
        with:
          github_token: "${{ secrets.PYVISTA_BOT_TOKEN }}"
          labels: docker
      - uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf
        if: startsWith(github.event.pull_request.head.ref, 'maint') || startsWith(github.event.pull_request.head.ref, 'testing') || startsWith(github.event.pull_request.head.ref, 'no-ci') || startsWith(github.event.pull_request.head.ref, 'ci')
        with:
          github_token: "${{ secrets.PYVISTA_BOT_TOKEN }}"
          labels: maintenance
      - uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf
        if: startsWith(github.event.pull_request.head.ref, 'junk')
        with:
          github_token: "${{ secrets.PYVISTA_BOT_TOKEN }}"
          labels: ignore-for-release
      - uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf
        if: startsWith(github.event.pull_request.head.ref, 'feat')
        with:
          github_token: "${{ secrets.PYVISTA_BOT_TOKEN }}"
          labels: enhancement
      - uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf
        if: startsWith(github.event.pull_request.head.ref, 'fix') || startsWith(github.event.pull_request.head.ref, 'patch') || startsWith(github.event.pull_request.head.ref, 'bug')
        with:
          github_token: "${{ secrets.PYVISTA_BOT_TOKEN }}"
          labels: bug
      - uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf
        if: startsWith(github.event.pull_request.head.ref, 'release')
        with:
          github_token: "${{ secrets.PYVISTA_BOT_TOKEN }}"
          labels: release
      - uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf
        if: startsWith(github.event.pull_request.head.ref, 'breaking-change')
        with:
          github_token: "${{ secrets.PYVISTA_BOT_TOKEN }}"
          labels: breaking-change
