# Docs

# Label Config

# labeler:
#   - settings:
#     - codeOwnersPath: {PATH TO CODEOWNERS FILE (defaults to .github/CODEOWNERS)}
#   - labels:
#     - label: {YOUR LABEL NAME}
#       condition: {AND (default) | OR}
#       when:
#         {TEST_FUNCTION}: {REGEX}
#         ...
#     ...

#| Function Name               | Description                                                                |
#| --------------------------- | -------------------------------------------------------------------------- |
#| `isAnyFilePathMatch`        | Returns true if any filename in the PR diff matches the given regex        |
#| `isPRBodyMatch`             | Returns true if the PR description matches the given regex                 |
#| `isPRTitleMatch`            | Returns true if the PR title matches the given regex                       |
#| `isPRAuthorMatch`           | Returns true if the PR author matches the given regex                      |
#| `isPRAuthorCompanyMatch`    | Returns true if the PR author's company matches the given regex            |
#| `isAnyFileOwnedByMatch`     | Returns true if any owner of a file in the PR diff matches the given regex |
#| `isNotAnyFilePathMatch`     | The negation of `isAnyFilePathMatch`                                       |
#| `isNotPRBodyMatch`          | The negation of `isPRBodyMatch`                                            |
#| `isNotPRTitleMatch`         | The negation of `isPRTitleMatch`                                           |
#| `isNotPRAuthorMatch`        | The negation of `isPRAuthorMatch`                                          |
#| `isNotPRAuthorCompanyMatch` | The negation of `isPRAuthorCompanyMatch`                                   |
#| `isNotAnyFileOwnerByMatch`  | The negation of `isAnyFileOwnedByMatch`                                    |

labeler:
  labels:
    # Removes the PR from release notes when its chore or ci
    - label: "release-notes-ignore"
      when:
        isPRTitleMatch: "^(?:(\bchore\b|\bci\b)|.*?\\((\bchore\b|\bci\b)\\)).*?:"

    # areas
    - label: "area: ci"
      when:
        isAnyFilePathMatch: '^\.github\/(workflows|actions).*$'
    - label: "area: examples"
      when:
        isAnyFilePathMatch: '^examples\/.*$'
    - label: "area: docs"
      when:
        isAnyFilePathMatch: '^docs\/.*\.mdx$'
    - label: "area: site"
      when:
        isAnyFilePathMatch: '^docs\/.*\.(?!mdx).*$'

    # packages
    - label: "pkg: turbo-eslint"
      when:
        isAnyFilePathMatch: '^packages\/eslint-(plugin|config)-turbo\/.*$'
    - label: "pkg: turbo-ignore"
      when:
        isAnyFilePathMatch: '^packages\/turbo-ignore\/.*$'
    - label: "pkg: turbo-codemod"
      when:
        isAnyFilePathMatch: '^packages\/turbo-codemod\/.*$'
    - label: "pkg: create-turbo"
      when:
        isAnyFilePathMatch: '^packages\/create-turbo\/.*$'
    - label: "pkg: turbo-gen"
      when:
        isAnyFilePathMatch: '^packages\/turbo-gen\/.*$'
    - label: "pkg: turbo-workspaces"
      when:
        isAnyFilePathMatch: '^packages\/turbo-workspaces\/.*$'
    - label: "pkg: turbo-repository"
      when:
        isAnyFilePathMatch: '^packages\/turbo-repository\/.*$'
    - label: "pkg: turbo-telemetry"
      when:
        isAnyFilePathMatch: '^packages\/turbo-telemetry\/.*$'

    # release
    - label: "release: turborepo"
      when:
        isAnyFilePathMatch: '^version\.txt$'
        isPRTitleMatch: '^release\(turborepo\):.*$'
events:
  onPublish:
    turbo:
      - runWorkflow: bench-turborepo.yml
        when: any
      - runWorkflow: update-examples-on-release.yml
        when: latest
