Giter VIP home page Giter VIP logo

assign-reviewers-by-labels-action's Introduction

Assign Reviewers By Labels

Automatically assign reviewers to pull requests using labels.

Usage

Add a .github/assign_label_reviewers.yml file

To assign reviewers using labels, provide an object with the key as the label and the value as an array of reviewers.

assign:
  login: ['ljbc1994', 'reviewer2', 'reviewer3']
  signup: ['reviewer4', 'reviewer5']
  dashboard: ['ljbc1994', 'reviewer6']

Create Workflow

Create a workflow in your repository, you only need to trigger the workflow when a label has been added or removed:

Basic Workflow

name: "Pull Request Label Reviewers"
on:
  pull_request:
    types:
      - unlabeled
      - labeled

jobs:
  assign_and_unassign:
    name: assign and unassign reviewers
    runs-on: ubuntu-latest
    steps:
      - name: main
        id: assign-reviewers
        uses: totallymoney/assign-reviewers-by-labels-action@v1
        with:
          repo-token: "${{ secrets.GITHUB_TOKEN }}"

Advanced Workflow

name: "Pull Request Label Reviewers"
on:
  pull_request:
    types:
      - unlabeled
      - labeled

jobs:
  assign_and_unassign:
    name: assign and unassign reviewers
    runs-on: ubuntu-latest
    steps:
      - name: main
        id: assign_reviewers
        uses: totallymoney/assign-reviewers-by-labels-action@v1
        with:
          repo-token: "${{ secrets.GITHUB_TOKEN }}"
      - name: assigned reviewers
        if: steps.assign_reviewers.outputs.assigned_status == 'success'
        run: |
          echo "reviewers assigned: ${{ steps.reviewer.outputs.assigned_reviewers }}"
      - name: unassigned reviewers
        if: steps.assign_reviewers.outputs.unassigned_status == 'success'
        run: |
          echo "reviewers unassigned: ${{ steps.reviewer.outputs.unassigned_reviewers }}"

Inputs ➡️ Outputs

Action inputs

Name Description Required Default
repo-token Token to use to authorize label changes. Typically the GITHUB_TOKEN secret, with contents:read and pull-requests:write access true N/A
unassign-if-label-removed Whether to unassign reviewers that belong to a label if the label has been removed true true
config-file The path to the label configuration file or endpoint that returns JSON configuration file false .github/assign_label_reviewers.yml
config-request-headers The headers to be passed when calling an endpoint to return the JSON configuration file false N/A

Action outputs

Name Description
assigned_status Whether reviewers have been assigned (success / info)
assigned_message Additional details of the status
assigned_url The url of the PR
assigned_reviewers The reviewers that have been assigned
unassigned_status Whether reviewers have been unassigned (success / info)
unassigned_message Additional details of the status
unassigned_url The url of the PR
unassigned_reviewers The reviewers that have been unassigned

Examples

Using a remote config

If you want to retrieve the config from an endpoint, we also support this.

Please note:

  • We only allow retrieving the config using a GET request with the ability to pass through custom headers if you need to pass an api token (config-request-headers).
  • The endpoint MUST return the config in the JSON format.

Example Config

{
  "assign": {
    "login": ["ljbc1994", "reviewer2", "reviewer3"]
  }
}

Example Workflow

name: "Pull Request Label Reviewers"
on:
  pull_request:
    types:
      - unlabeled
      - labeled

jobs:
  assign_and_unassign:
    name: assign and unassign reviewers
    runs-on: ubuntu-latest
    steps:
      - name: main
        id: assign_reviewers
        uses: totallymoney/assign-reviewers-by-labels-action@v1
        with:
          repo-token: "${{ secrets.GITHUB_TOKEN }}"
          config-file: 'https://www.totallymoney.com/assign-reviewers-label-config.json'
          config-request-headers: '{"Authorization": "Bearer ${{ secrets.API_TOKEN }}"}'

assign-reviewers-by-labels-action's People

Contributors

dependabot[bot] avatar ljbc1994 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

assign-reviewers-by-labels-action's Issues

Config file not found

I'm having an issue in which the workflow is not able to find the config file. I have placed the config file in .github and named it the using the default value. I also tried explicitly setting the path to the config file in the workflow, yielding the same result.

My workflow:
`name: "Auto Assign Reviewers"
on:
pull_request:
types:
- unlabeled
- labeled

jobs:
assign_and_unassign:
name: assign and unassign reviewers
runs-on: ubuntu-latest
steps:
- name: main
id: assign-reviewers
uses: totallymoney/[email protected]
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
`

My config file (in project):
image

Debug Output:
##[debug]Evaluating condition for step: 'main' ##[debug]Evaluating: success() ##[debug]Evaluating success: ##[debug]=> true ##[debug]Result: true ##[debug]Starting: main ##[debug]Loading inputs ##[debug]Evaluating: secrets.GITHUB_TOKEN ##[debug]Evaluating Index: ##[debug]..Evaluating secrets: ##[debug]..=> Object ##[debug]..Evaluating String: ##[debug]..=> 'GITHUB_TOKEN' ##[debug]=> '***' ##[debug]Result: '***' ##[debug]Loading env Run totallymoney/[email protected] with: config-file: .github/assign_label_reviewers.yml repo-token: *** unassign-if-label-removed: true ##[debug]📄 Retrieving config from yaml file... Error: Failed to load configuration 7dd6[3](https://github.com/everwise/integration-service/actions/runs/3107132237/jobs/5035150668#step:2:3)f[7](https://github.com/everwise/integration-service/actions/runs/3107132237/jobs/5035150668#step:2:7) Not Found .github/assign_label_reviewers.yml ##[debug]Node Action run completed with exit code 1 ##[debug]Finishing: main

Thank you!

Support team reviewers

What's the suggestion?

At the moment, the workflow only supports reviewers as opposed to team reviewers. This should be added!

Do not fail if assigns PR author

Hi just started using the action but we have another action that adds labels and then this action to assign the reviewer.

The problem arises if I am the member to be marked as a reviewer for that label I get the following error (assuming this is flowing through from github)

Review cannot be requested from pull request author

Do we think it's nice to handle this case and still add the other reviewers?

Bump @actions/core to latest

I get the following warning when I use this action.

Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

I think upgrading to the latest version of @actions/core (1.10.0) will fix this warning.

#104

Could this pull request be merged?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.