Varun-Kolanu / issue-assigner

A bot for managing issue assignments
https://probot.github.io/apps/issue-assigner/
ISC License
7 stars 2 forks source link
bot github-app integration-testing issue-assignment issue-management nock node probot-app unit-testing

GitHub Issue Assigner Bot

This GitHub bot helps manage issue assignments in a repository by automatically assigning or unassigning issues based on predefined rules and user commands in comments. The bot is implemented using Probot, a framework for building GitHub Apps.

If you find this project helpful, please consider giving it a star ā­ on GitHub. It helps others discover the project and shows your appreciation for the work!

See probot published app here, and live listing on GitHub Marketplace here

Features

Note for maintainers:

Assignment and Abandoning of issues doesn't work for users having permissions admin, maintainer or triage, since they already can assign themselves and also to avoid accidental assignment of the issue while explaining a contributor how to claim.

Usage

  1. Install the bot in your account.

  2. After installing the bot, create a file .github/issue-assigner.yml in the repo and paste the following content:

    # Remove or comment the line from yml if you don't need that feature
    
    # The name of bot you would like to be mentioned by users. {name} will be replaced by the below name
    name: "issue-assigner"
    
    ######################## Issue assignment ########################
    
    # Prompt entered by user to request assign the issue to him/her
    assign-prompt: "@{name} claim" # For example, @issue-assigner claim
    
    # Comment from bot if the issue got already assigned to the user requesting
    issue-already-assigned: "You have already been assigned to this issue."
    
    # Maximum number of assignees for an issue
    max-assignees: 1
    
    # Maximum number of assignees reached for the requested issue
    max-assignees-reached: "Sorry, maximum limit for assignees in this issue has reached. Please check other issues or contact a maintainer."
    
    # Maximum number of open issues a user can have assigned at a time in the repo
    max-issues-for-user: 1
    
    # If all OK, the comment from bot to tell that issue got assigned
    assigned-comment: "This issue has been successfully assigned to you! šŸš€"
    
    ######################## Issue un-assignment ########################
    
    # Prompt entered by user to request un-assignment of the issue to him/her
    unassign-prompt: "@{name} abandon"
    
    # If the issue was already not assigned to the user
    issue-was-not-assigned: "You were not assigned to this issue."
    
    # If criteria is matched, the issue will get un-assigned
    unassigned-comment: "You have been unassigned to this issue successfully."
    
    ######################## Issue Opened ########################
    
    # If the user who opened issue is NOT a maintainer of the repo
    issue-opener-not-maintainer: "Thank you for opening this issue. Maintainers will check and approve if seems to be useful."
    
    # If the user who opened issue IS a maintainer of the repo
    issue-opener-is-maintainer: "Comment '@{name} claim' to get this issue assigned or '@{name} abandon' to get this issue unassigned."
  3. You can remove a line from yml if you don't need that feature.

  4. You can edit the values in the yml to customize the comments from the bot.

  5. For example, commenting '@issue-asigner claim' will assign the issue and '@issue-assigner abandon' will remove the assignment.

See these issues for seeing all features practically: #3 and #4

See Contributing guide for contributing to the project.

Running in local system

  1. Clone the repo with

    git clone https://github.com/Varun-Kolanu/issue-assigner.git
  2. Install dependencies

    npm install
  3. Run the development server

    npm run dev
  4. Open the link that you see in terminal to install install and configure your GitHub app.

  5. You can see .env being filled with required credentials.

  6. Or to configure manually, create a new github app and make a .env in the root, taking .env.example as a reference.

  7. Create a .github/issue-assigner.yml file in the installed repo with the example configuration given above.

  8. You can test the app in your GitHub issues directly now.

Folder structure

.
ā”œā”€ā”€ .github/                          ## configuration files
ā”‚ ā””ā”€ā”€ issue-assigner.yml
ā”œā”€ā”€ assets/                           ## assets like images, icons, etc
ā”œā”€ā”€ src/                              ## main source code
ā”‚ ā”œā”€ā”€ classes/                        # classes for event handlers defined
ā”‚ ā”œā”€ā”€ handlers/                       # functions to handle webhook events from github
ā”‚ ā”‚ ā”œā”€ā”€ issue_comment.js
ā”‚ ā”‚ ā””ā”€ā”€ issue_opened.js
ā”‚ ā”œā”€ā”€ helpers/                        # utility functions to help handlers
ā”‚ ā”œā”€ā”€ app.js                          # main file which exports probot app
ā”‚ ā””ā”€ā”€ server.js                       # server for the app
ā”œā”€ā”€ test/                             ## tests for app
ā”‚ ā”œā”€ā”€ fixtures/                       # mock data for testing
ā”‚ ā”œā”€ā”€ integration/                    # integration tests
ā”‚ ā”œā”€ā”€ unit/                           # unit tests
ā”‚ ā””ā”€ā”€ utils/                          # utility functions for tests
ā”œā”€ā”€ CONTRIBUTING.md                   ## Contributing Guide
ā””ā”€ā”€ README.md                         ## Readme

License

ISC Ā© 2024 Varun Kolanu