Skip to content
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

Merged
merged 7 commits into from
Feb 4, 2020

Conversation

tagoro9
Copy link
Contributor

@tagoro9 tagoro9 commented Jan 31, 2020

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.

@tagoro9 tagoro9 requested a review from kentaro-m January 31, 2020 17:45
Copy link
Owner

@kentaro-m kentaro-m left a 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:
Copy link
Owner

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?

Copy link
Contributor Author

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


async hasAnyLabel(labels: string[]): Promise<boolean> {
const { owner, repo, number: pull_number } = this.context.issue
const pullRequestLabels = (await this.client.issues.listLabelsOnIssue({
Copy link
Owner

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.

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

Copy link
Owner

@kentaro-m kentaro-m left a 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.

@kentaro-m kentaro-m merged commit 083e813 into kentaro-m:master Feb 4, 2020
@kentaro-m
Copy link
Owner

@tagoro9
This feature released as v1.1.0 🎉
https://github.com/kentaro-m/auto-assign-action/releases/tag/v1.1.0

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 }}"

@tagoro9 tagoro9 deleted the add_support_for_label_filter branch February 4, 2020 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants