DEV Community

Toshimaru
Toshimaru

Posted on

Label-based Reviewer Auto-assign Action

My Workflow

Want to assign a reviewer based on a label❓

Here's my GitHub Action: https://github.com/toshimaru/label-actions

label added and reviewer is assigned automatically

Submission Category:

🔧 Maintainer Must-Haves

Yaml File or Link to Code

.github/workflows/label-actions.yml

Your main workflow definition:

name: 'Label Actions'

on:
  pull_request:
    types: [labeled, unlabeled]

jobs:
  job:
    runs-on: ubuntu-latest
    steps:
      - uses: toshimaru/label-actions
        with:
          github-token: ${{ github.token }}
          process-only: 'prs'
Enter fullscreen mode Exit fullscreen mode

.github/label-actions.yml

Your label-action configuration.

'review wanted':
  prs:
    reviewers:
      - toshimaru
      - github-username1
      - github-username2
      - github-username3
      - github-username4
      - github-username5
    number-of-reviewers: 2 # default is 1
Enter fullscreen mode Exit fullscreen mode

More details on README

GitHub logo toshimaru / label-actions

🤖 GitHub Action that performs certain actions when issues or pull requests are labeled or unlabeled

Build Script

Label Actions

Label Actions is a GitHub bot that performs certain actions when issues or pull requests are labeled or unlabeled.

How It Works

The bot performs certain actions when an issue or pull request is labeled or unlabeled. No action is taken by default and the bot must be configured. The following actions are supported:

  • Post comments
  • Add labels
  • Remove labels
  • Close threads
  • Reopen threads
  • Lock threads with an optional lock reason
  • Unlock threads
  • Assign reviewers

Usage

  1. Create the .github/workflows/label-actions.yml workflow file use one of the example workflows to get started
  2. Create the .github/label-actions.yml configuration file based on the example below
  3. Start labeling issues and pull requests

Inputs

The bot can be configured using input parameters.

  • github-token
    • GitHub access token, value must be ${{ github.token }} or an encrypted secret that contains a personal access token
    • Optional, defaults to ${{ github.token }}
  • config-path
    • Configuration file path
    • Optional, defaults…

Additional Resources / Info

Real-world use case: labeler + label-action

You can automate reviewer assign based on the code you change.

  • labeler adds a label based on the path of the changed files
  • label-action is triggered by the label added by labeler
  • label-action assigns a reviewer based on the label

GitHub official reviewer assignment feature

GitHub also provides a feature of auto reviewer assignment.

Managing code review settings for your team - GitHub Docs

If you want to assign a reviewer based on the team, This fits you!

This is a fork repo

This project is a fork of dessant/label-actions. Special thanks to original author, dessant! ❤️

Top comments (0)