mheap / github-action-required-labels

Fail the build if/unless a certain combination of labels are applied to a pull request
MIT License
99 stars 23 forks source link

Thoughts on supporting case insensitivity? #75

Closed codfish closed 6 months ago

codfish commented 6 months ago

Thoughts on supporting case insensitivity out of the box OR adding it as an input?

https://github.com/mheap/github-action-required-labels/blob/main/index.js#L93C7-L93C77

- const appliedLabels = labels.map((label) => label.name);
+ const appliedLabels = labels.map((label) => label.name);
+ const lowerCaseAppliedLabels = appliedLabels.map((label) => label.toLowerCase());

- intersection = providedLabels.filter((x) => appliedLabels.includes(x))
+ intersection = providedLabels.filter((x) => lowerCaseAppliedLabels.includes(x.toLowerCase()))

The use case here is that we want to use this in a composite across repos but some repos have a "Do Not Merge" label spelled in different ways. In order to appropriately handle this, we have to do something like:

    - uses: mheap/github-action-required-labels@fab3b73a9443656a796639b75fe08d4eb8c75e75
      with:
        mode: exactly
        count: 0
        labels: "DO NOT MERGE, Do Not Merge, Do not merge, do not merge"
        add_comment: true

But that's obviously got a little bit of a smell to it, and the comment that get's posted isn't ideal.

mheap commented 6 months ago

Out of the box makes sense to me. I’ve not seen any real world use case for case sensitive labels

codfish commented 6 months ago

@mheap OK sounds good, I can put together a PR today for your review!

codfish commented 6 months ago

@mheap here you go! https://github.com/mheap/github-action-required-labels/pull/76

mheap commented 6 months ago

This was released in https://github.com/mheap/github-action-required-labels/releases/tag/v5.4.0