Skip to content

mdzhang/pr-codeowner-autolabel-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

PR Codeowner Autolabel Action

GitHub Super-Linter CI Check dist/ CodeQL Coverage

Add labels to GitHub PRs based on the contents of CODEOWNERS

Usage

jobs:
  permissions:
    contents: read
    pull-requests: write
  steps:
    - name: Checkout
      id: checkout
      uses: actions/checkout@v4

    - name: PR Codeowner Autolabel
      id: pr-codeowner-autolabel
      uses: mdzhang/pr-codeowner-autolabel
      with:
        # default is CODEOWNERS
        file-path: .github/CODEOWNERS
        repo-token: ${{ secrets.GITHUB_TOKEN }}
        labels-to-owners: |
          {
            "frontend": "@myteam/@frontend-guild"
          }

Note that dependabot PRs will get labeled by default as well! If not desired add the following to the workflow:

if: ${{ github.actor != 'dependabot[bot]' }}

Permissions

In order to add labels to pull requests, this action requires write permissions on the pull-request. Refer to the GitHub token permissions documentation for more details about access levels and event contexts.

Contributing

See CONTRIBUTING.md for information on how to contribute.