feat: add label filter to reduce scope of action#14
Conversation
…specified labels It is a noop if no labels are configured
| The action will only run if the PR has any of the specified labels | ||
|
|
||
| ```yaml | ||
| labels: |
There was a problem hiding this comment.
The action will only run if the PR has any of the specified labels
[IMO] On the other hand, I think there might be use cases not to run the action if adding specific labels to a pull request. Therefore I came up with an idea which labels can be set separately for include and exclude.
Also, add a property called filterLabels to clarify what the labels property is used for (e.g. skipKeywords: A list of keywords to be skipped the process that add reviewers if pull requests include it).
Suggest a configuration file format, such as:
filterLabels:
# Run
include:
- my_label
- another_label
# Not Run
exclude:
- wipWhat do you think of this suggestion of mine?
There was a problem hiding this comment.
Thanks for your feedback! I think this makes sense. I'll update the code to support this
|
|
||
| async hasAnyLabel(labels: string[]): Promise<boolean> { | ||
| const { owner, repo, number: pull_number } = this.context.issue | ||
| const pullRequestLabels = (await this.client.issues.listLabelsOnIssue({ |
There was a problem hiding this comment.
[INFO] Label data added to the pull request may be available from a webhook payload. If this is available, codes for calling the API to fetch labels data can be removed.
auto-assign-action/src/handler.ts
Line 31 in 6c480d0
context.payload.pull_request.labels
GitHub Document:
https://developer.github.com/v3/activity/events/types/#pullrequestevent
|
@tagoro9 It works with the following configuration file: name: 'Auto Assign'
on: pull_request
jobs:
add-reviews:
runs-on: ubuntu-latest
steps:
- uses: kentaro-m/auto-assign-action@v1.1.0
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}" |
Thanks for this really cool action! I started to use it, but realized that I needed it to only run in PRs that had certain labels.
This PR adds support to specify a list of labels that a pull request must have to trigger the action. If the target PR doesn't have any of the specified labels, then the action is skipped.