labeler icon indicating copy to clipboard operation
labeler copied to clipboard

Assigns labels based on branch names

Open joshdales opened this issue 3 years ago • 34 comments

Assign a label based on the branch name! (Closes #186)

Depending on your branch name you may want to apply different labels based on the purpose of the branch.

eg. say that you wanted to something like:

feature:
 - branch: feature/*
bug:
 - branch: */bug/*

It would apply the feature label to the branch to feature/add-the-new-thing branch, and the bug label to the josh/bug/fix-the-new-thing branch.

You can also provide a list of arguments in the config

release:
 - branch: ['release/*', 'hotfix/**']

joshdales avatar Aug 07 '21 19:08 joshdales

FYI: I found that this wasn't working for me as expected. I got it working for me in https://github.com/joshdales/labeler/pull/1. I didn't spend much time writing up any context, partly because this PR doesn't have any response, so I'm not sure if anyone is planning to take the time to review this. I'd be happy to communicate more about it if there's interest.

EDIT: Updated PR reference.

amiel avatar Sep 15 '21 18:09 amiel

@amiel If it's not working properly I'm still interested so would appreciate any information you can give 😄

joshdales avatar Sep 15 '21 18:09 joshdales

Hi @joshdales. I just realized that I referenced the wrong pull request in my last comment. I've edited it to reference the one I meant to reference: https://github.com/joshdales/labeler/pull/1.

The problem I ran in to was that github.context.ref was producing something like refs/pull/23/head, which would not match my branch names like feature/foo.

Using github.context.payload.pull_request.head.ref resolves this for me and uses the branch name that I actually want to match on. I don't have a lot of experience with github actions, but I found this object path here: https://github.com/TimonVS/pr-labeler-action/blob/master/src/action.ts#L25.

amiel avatar Sep 15 '21 19:09 amiel

I also considered updating your changes to support a list of branch patterns, just like the way lists of files are supported. However, I got it working by using the glob matching and I added a test to demonstrate that. This took me a little while to figure out because the minimatch documentation shows an example with (bar|foo), but I needed to use the glob syntax ({bar,foo}) instead.

amiel avatar Sep 15 '21 19:09 amiel

@amiel took your suggestion and I've updated this PR to support a list of branch arguments as well 👍

joshdales avatar Sep 30 '21 12:09 joshdales

@joshdales Awesome! I'll pull those changes upstream too since we are pinned to our branch until this gets actually released.

amiel avatar Sep 30 '21 18:09 amiel

Be cool to get this feature shipped. I'd selfishly find it useful.

david-heward-unmind avatar Dec 10 '21 17:12 david-heward-unmind

You should update the README.md file to documenting your feature.

Alvaro-Campesino avatar Jan 28 '22 09:01 Alvaro-Campesino

Any updates on this?

justin-kidman-axomic avatar Feb 17 '22 14:02 justin-kidman-axomic

Any chance we can get this merged soon?

lucacome avatar Mar 09 '22 21:03 lucacome

Any updates @DennisBoanini @pje ?

arivera-xealth avatar Mar 18 '22 17:03 arivera-xealth

Any updates @DennisBoanini @pje ?

I don't know, the owner of the PR is @joshdales, I only add a suggestion

DennisBoanini avatar Mar 30 '22 14:03 DennisBoanini

I see that there is 1 pending reviewer and the branch have conflicts. Any change to merge this PR?

DennisBoanini avatar Mar 30 '22 14:03 DennisBoanini

@DennisBoanini @arivera-xealth I tried to keep it updated and added to it for a while but it felt kinda fruitless after 5 months 😞

Happy to come back and make the suggestions and fix those conflicts once a code owner has looked at it

joshdales avatar Mar 30 '22 15:03 joshdales

@joshdales review received. would love to see this being merged.

franklinkim avatar Jun 07 '22 06:06 franklinkim

@franklinkim the review isn't from a code owner so it can't be merged 😢

joshdales avatar Jun 08 '22 18:06 joshdales

😭

franklinkim avatar Jun 09 '22 05:06 franklinkim

Guys, why this PR still cannot be merged?

DennisBoanini avatar Jun 09 '22 07:06 DennisBoanini

@DennisBoanini I can't merge it without it being reviewed by a code owner first.

I've fixed the merge conflict though and added some notes to the readme to try and breathe some life back into this PR.

@pje Any chance that you or someone else on the actions team could take a look?

joshdales avatar Jun 11 '22 17:06 joshdales

@pje 👇 Any chance that you or someone else on the actions team could take a look?

adilnaimi avatar Jun 18 '22 10:06 adilnaimi

I wonder what's going on with this repo and the maintainers. This PR was opened more than a year ago and there's clearly a lot of interest in the feature, but not even one response from the maintainers. 😞

lucacome avatar Aug 16 '22 17:08 lucacome

I wonder what's going on with this repo and the maintainers. This PR was opened more than a year ago and there's clearly a lot of interest in the feature, but not even one response from the maintainers. 😞

You're right, that's incredible. I don't understand why.

DennisBoanini avatar Aug 16 '22 18:08 DennisBoanini

Who is the one that can accept this PR?

DennisBoanini avatar Aug 16 '22 18:08 DennisBoanini

I wonder what's going on with this repo and the maintainers. This PR was opened more than a year ago and there's clearly a lot of interest in the feature, but not even one response from the maintainers. 😞

Also interested in this feature

elendil-software avatar Aug 17 '22 17:08 elendil-software

@pje any chance you want to take this up in your project? It looks like a really nice addition I would definitely use

maistrotoad avatar Aug 24 '22 06:08 maistrotoad

maybe @chrispat ?

lucacome avatar Aug 25 '22 00:08 lucacome

Hi @joshdales. Thanks for maintaining this branch despite the lack of review from an actual code owner. I know it has been frustrating. I appreciate it as my team and I are still using this in daily builds.

Something happened with the most recent commit (0ad789c) and we're getting this error:

| /run/act/actions/joshdales-labeler@main/dist/index.js:14965
| util.inherits(TunnelingAgent, events.EventEmitter);
|      ^
| 
| TypeError: util.inherits is not a function

Also, it looks like my changes from joshdales#1 are not included anymore. I have hard-coded our action to use joshdales/labeler@6e276063fecb6573bf5dc89df1f4a1e317e3a6ce, which is still working for me.

Anyway, I just wanted to let you know that something doesn't seem right with that last merge. Thanks again.

amiel avatar Aug 30 '22 18:08 amiel

@amiel Ahh damn - that'll teach me to merge late at night 😞.

Thanks for letting me know I'll take a look at this tonight or tomorrow and try and get it fixed 👍

joshdales avatar Aug 30 '22 18:08 joshdales

Thanks @joshdales!

amiel avatar Aug 30 '22 19:08 amiel

Okay I've got it working again! 🎉 https://github.com/joshdales/glowing-octo-disco/pull/1

Seems that I just needed to run the build command again

joshdales avatar Aug 30 '22 21:08 joshdales