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

Add config option to only apply first match #52

Open
KevinBatdorf opened this issue Jan 5, 2022 · 2 comments · May be fixed by #82
Open

Add config option to only apply first match #52

KevinBatdorf opened this issue Jan 5, 2022 · 2 comments · May be fixed by #82

Comments

@KevinBatdorf
Copy link

I'd like to have a fallback label applied without any matches.

feature: ['feature/*', 'feat/*']
fix: fix/*
chore: chore/*
unknown: *

So if nothing matches, it will add the label "unknown"

I was thinking you could add a config option where it would return on the first match instead of looping through each (then it would use the * as the fallback if nothing else matched). Does that seem feasible?

@w5l
Copy link

w5l commented Feb 21, 2022

This might be a lot easier to do using the action config instead of in the tags yml.

For example:

    steps:
      - uses: TimonVS/pr-labeler-action@v3
        with:
          default-label: 'unknown' # Any PR not matching one of the rules gets this label
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Can be done by a default-label string option, or by having a first-match-only boolean option.

An interesting thing to keep in mind, a "default label" would be slightly different behavior than a "first match only" in more complex configurations.

@TimonVS
Copy link
Owner

TimonVS commented Nov 15, 2022

Great idea. We cannot use the syntax you originally proposed because it's already occupied (currently, this will always add the label, regardless of any other matches). @w5l's proposal should work though! This should be relatively easy to implement, feel free to open a PR for it if you wish.

@jamesrenaud jamesrenaud linked a pull request Aug 23, 2023 that will close this issue
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 a pull request may close this issue.

3 participants