Skip to content

elastic/auto-assign-issue

 
 

Repository files navigation

GitHub action that auto-assigns issues or PRs to users or team members

CI Workflow codecov GitHub Marketplace

Inputs

Parameter Type Required Default Description
assignees String false n/a Comma separated list of user names. Issue will be assigned to those users.
unassignees String false n/a Comma separated list of user names to be unassigned.
teams String false n/a Comma separated list of team names without the org prefix. Issue will be assigned to the team members.

Important Requirement: if using the teams input parameter, you need to use a personal access token with read:org scope (the default GITHUB_TOKEN is not enough).
numOfAssignee Number false n/a Number of assignees that will be randomly picked from the teams or assignees. If not specified, assigns all users.
abortIfPreviousAssignees Boolean false false Flag that aborts the action if there were assignees previously.
removePreviousAssignees Boolean false false Flag that removes assignees before assigning them (useful the issue is reasigned).
allowNoAssignees Boolean false false Flag that prevents the action from failing when there are no assignees.
allowSelfAssign Boolean false true Flag that allows self-assignment to the issue author.

This flag is ignored when working with PRs as self assigning a PR for review is forbidden by GitHub.

Examples

Working with Issues

This example auto-assigns new issues to two users randomly chosen from octocat, cat and dog. It won't self-assign to the issue author.

name: Issue assignment

on:
    issues:
        types: [opened]

jobs:
    auto-assign:
        runs-on: ubuntu-latest
        steps:
            - name: 'Auto-assign issue'
              uses: pozil/auto-assign-issue@v1
              with:
                  assignees: octocat,cat,dog
                  numOfAssignee: 2
                  allowSelfAssign: false

Working with PRs

This example assigns PRs to a random member of the support team:

name: PR assignment

on:
    pull_request:
        types: [opened, edited, synchronize, reopened]

jobs:
    auto-assign:
        runs-on: ubuntu-latest
        steps:
            - name: 'Auto-assign PR'
              uses: pozil/auto-assign-issue@v1
              with:
                  repo-token: ${{ secrets.MY_PERSONAL_ACCESS_TOKEN }}
                  teams: support
                  numOfAssignee: 1

Working with Project Cards

Warning > project_card events are only supported on legacy Project (Classic) (see docs).

This example assigns a project card to the triage team when the card is moved. It removes previously assigned users.

name: Project card assignment

on:
    project_card:
        types: [moved]

jobs:
    auto-assign:
        runs-on: ubuntu-latest
        steps:
            - name: 'Auto-assign card'
              uses: pozil/auto-assign-issue@v1
              with:
                  repo-token: ${{ secrets.MY_PERSONAL_ACCESS_TOKEN }}
                  teams: triage
                  removePreviousAssignees: true

Specifying a dynamic user

Instead of hardcoding the user name in the workflow, you can use a secret:

  • create a GitHub secret named DEFAULT_ISSUE_ASSIGNEE with the name of the user
  • use this value ${{ secrets.DEFAULT_ISSUE_ASSIGNEE }} instead of the username in the workflow.

About

GitHub Action that auto-assigns issues or PRs to one or more users

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.8%
  • Shell 0.2%