-
-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add label filter to reduce scope of action #14
feat: add label filter to reduce scope of action #14
Conversation
…specified labels It is a noop if no labels are configured
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @tagoro9. Thank you for adding a nice new feature!
I checked this PR and add some comments.
Please check my comments and let me know if you have any questions.
README.md
Outdated
The action will only run if the PR has any of the specified labels | ||
|
||
```yaml | ||
labels: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
- wip
What do you think of this suggestion of mine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your feedback! I think this makes sense. I'll update the code to support this
src/pull_request.ts
Outdated
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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
const { title, draft, user, number } = context.payload.pull_request |
context.payload.pull_request.labels
GitHub Document:
https://developer.github.com/v3/activity/events/types/#pullrequestevent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for your changes.
@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.