Github action for automatically adding labels and/or setting assignees when an Issue or PR is opened or edited based on user-defined Area
This action will automatically determine a single area out of many to which an issue belongs based on a list of keywords. It will then automatically add labels and set assignees to that issue depending on which area the issue lies in.
This is useful for repositories with many different clear areas of responsibility. See the AWS CDK repository for an example of how this action can be configured.
Each area is given a score which is added to every time a keyword for that particular area is in the issue. The area with the highest score is determined to be the winning area
The value of words in the title of the issue starts with 1 for the first word, and each word decreases in value logarithmically The value of words in the body of the issue are worth a constant value which can be set by the user
Keywords don't have to be an exact match for the word to count. You can allow for slight amount of user error by tuning the similarity
input. A value of 0 means that keywords have to be an exact match
- Install dependencies with NPM
npm install
- Build the JS files
npm run build
Run all unit tests using Jest.
npm run test
Append -- --watch
to auto run tests when changes are saved.
Parameters should take the form
[
{
"area": "area",
"keywords": ["keywords"],
"labels": ["labels"],
"assignees": ["assignees"],
"reviewers": {
"reviewers": ["reviewer1"],
"teamReviewers": ["team1"]
},
"affixes": {
"prefixes": ["prefix"],
"suffixes": ["suffix"]
}
}
]
note: labels
, assignees
, reviewers
, and affixes
are not required
note: reviewers
naturally only takes effect on PRs
Affixes (prefixes and suffixes) to append or prepend to all keywords
{
"prefixes": ["prefix"],
"suffixes": ["suffix"]
}
The original keywords you add to each area will still be checked. Affixes will only add keywords to check.
For example, if for an area you have an affix aws-
and a keyword ec2
, the keywords that will be checked for that area will be aws-ec2
and ec2
.
If no keywords are detected in your issue, set these default labels and assignees
{
"labels": ["labels"],
"assignees": ["assignees"],
"reviewers": {
"reviewers": ["reviewer1"],
"teamReviewers": ["team1"]
},
}
Select whether to run only on issues, pull requests, or both. Valid values are issues
, pull-requests
, and both
The default value is both
Setting this to true
will consider the title of the area to be a keyword of that area
You can exclude certain expressions from being potentially counted as keywords. This is useful if you have issue templates which may contain keywords.
The input should be an array with expressions to exclude separated by bars. Ex. [ Expression 1 | Expression 2 ]
A value of 0 means keywords have to match exactly. The algorithm used to determine the similarity of two strings is Levenshtein Distance
The default value is .125
A set constant for how much each keyword detected in the body of the issue is worth
The default value is .025
Conditionally run this action based on the labels present on the issue. Will only run on issues with any the specified labels
If no input is provided, the action will always run
Conditionally run this action based on the labels present on the issue. Will not run on issues with the specified labels
Overrides included-labels
name: "Set labels and assignees"
on:
issues:
types: [opened]
pull_request:
typed: [opened]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: aws-github-ops/aws-issue-triage-manager@main
with:
parameters: '[ {"area":"s3", "keywords": ["s3", "bucket"], "labels": ["s3"], "assignees": ["s3Dev"]}, {"area": "ec2", "keywords": ["ec2", "instance"], "labels": ["ec2"], "assignees": ["ec2Dev"]}]'
github-token: "${{ secrets.GITHUB_TOKEN }}"
excluded-expressions: "[ TypeScript | Java | Python ]"
Example of this action being configured and used in the AWS CDK repository
We welcome community contributions and pull requests. See CONTRIBUTING.md for information on how to contribute to this project
See CONTRIBUTING for more information.
This project is licensed under the Apache-2.0 License.