Joe PreviteJoe PreviteSee all posts

Auto-Assign Pull Requests on GitHub

Last updated:

Back when I was working at Echobind, we used a Slack + GitHub integration to notify you of PRs you needed to review. I loved it! As soon as a PR was assigned to me, I would get a ding on Slack. It worked really well.

Since we worked on small teams, the PR reviewers were always the same 1-2 devs. I thought,

Wouldn’t it be great if we could auto-assign them?

Turns out you can! Here’s how:

  1. Create a file called CODEOWNERS (no extension)
  2. Place it at the root or in the .github directory
  3. Add the following code to your file:
    # Make @lukeskywalker @yoda reviewers for every file
    *       @lukeskywalker @yoda

BOOM! And the cool part, you won’t be assigned your own pull requests (I don’t think you can be?)!

Note: you can get fancy and set up code owners for specific directories, extensions, etc. Read the docs.

If you prefer to learn by watching, you can find this on egghead.