Skip to content

feat: add label filter to reduce scope of action#14

Merged
kentaro-m merged 7 commits into
kentaro-m:masterfrom
tagoro9:add_support_for_label_filter
Feb 4, 2020
Merged

feat: add label filter to reduce scope of action#14
kentaro-m merged 7 commits into
kentaro-m:masterfrom
tagoro9:add_support_for_label_filter

Conversation

@tagoro9

@tagoro9 tagoro9 commented Jan 31, 2020

Copy link
Copy Markdown
Contributor

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

@kentaro-m kentaro-m left a comment

Copy link
Copy Markdown
Owner

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.

Comment thread README.md Outdated
The action will only run if the PR has any of the specified labels

```yaml
labels:

Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread 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({

Copy link
Copy Markdown
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

@kentaro-m kentaro-m left a comment

Copy link
Copy Markdown
Owner

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
Copy Markdown
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