Skip to content

CODEOWNERS on steroids: A GitHub Action built for monorepos.

License

Notifications You must be signed in to change notification settings

moltinginstar/anabolic-codeowners

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

Anabolic Codeowners logo

Anabolic Codeowners

CODEOWNERS on steroids. Built for monorepos.

License: MIT Contributor Covenant CI Check dist/ CodeQL Coverage

Anabolic Codeowners enhances GitHub’s CODEOWNERS functionality, enabling random assignment of code reviewers with per-path granularity. It’s perfect for monorepos, ensuring balanced review workload distribution.

Features

  • Randomly select reviewers from the configured pool to evenly distribute the review load
  • Assign reviewers to specific paths or files in your repository, mirroring CODEOWNERS syntax for intuitive setup
  • Flexibly set the number of reviewers per pull request to maintain balance between thorough review and efficiency

Usage

Definition

Create a workflow .yaml under .github/workflows like this:

name: Assign Reviewers

on:
  pull_request:
    types:
      - opened
      - reopened
      - ready_for_review

jobs:
  assign-reviewers:
    runs-on: ubuntu-latest
      steps:
        - name: Checkout code
          uses: actions/checkout@v4

        - name: Anabolic Codeowners
          uses: moltinginstar/anabolic-codeowners@main
          with:
            token: ${{ secrets.GITHUB_TOKEN }}
            config: .github/codeowners.yaml # Configuration file, optional
            num-reviewers: 1 # Reviewers per rule, optional

Configuration

To use Anabolic Codeowners, you must also create a configuration file and assign users to specific filepaths. By default, this file will be named .github/codeowners.yaml, or you can specify a different location in the workflow manifest. Here’s an example codeowners.yaml for an Nx-based monorepo:

**/*:
  - agile-codehunter
  - atomic-committer

apps/app1-api/**/*:
  - alluring-creator

# Override the default reviewers for a specific file
apps/app1-api/src/app.module.ts:
  - apex-codex

# Exclude specific paths from review
apps/app1-api/src/config/**/*:

apps/app1-api/**/*.(spec|test).ts:
  - agile-codehunter

apps/app1-web/**/*:
  - anomaly-catcher
  - aurora-cascade
  - apex-codex

libs/app1-shared/**/*:
  - agile-codehunter
  - aurora-cascade

The last matching rule for a file overrides previous matches. You can use any path specifier supported by minimatch, including:

  • * and **
  • Negative (!) patterns
  • POSIX character classes (e.g., [[:alpha:]])
  • Etc.

Contributing

Contributions are very welcome! Please submit pull requests or open issues for bugs and feature requests.

License

Anabolic Codeowners is licensed under the MIT License.