Return PR labels
riker09 opened this issue · 2 comments
Just as done in #1 there should be an output that return the PRs labels.
My use case: I want to check on each push if the associated PR has a certain label attached.
AFAIK, the "outputs" of an action can only be strings (this was certainly true when actions just came out of beta? I haven't tried it since then, although this seems to support that, even though those are job outputs and not step outputs). So unfortunately we probably can't just return an array of labels.
We could set some kind of environment variable like "PR_LABEL_BUG" if the PR has the label "bug"? We're supposed to declare all the available outputs in action.yml, so we probably shouldn't define outputs like "labels_bug"... although this says outputs will be available even if you don't declare them (then why do we need to declare them in the first place?) Outputs like this are nice, because they're scoped to the action, where environment variables are not. And then you could do if: steps.findpr.outputs.labels_bug
.
We could return a comma delimited list of labels? But would this fix your use case? You could do contains( steps.findpr.outputs.labels, 'bug' )
, but then this would find PRs with the label "bug" and also PRs with the label "bugle", so it's not perfect.
Hello, I've came up with my own action in the meantime that does what I needed. I based my work off of another community GitHub action https://github.com/Dreamcodeio/does-pr-has-label
Basically I did what you were saying, return a comma-separated list of the matched PRs. But also I've included a new parameter which determines if any or all the labels must match. And then I only check the second output of the action, hasLabel
which is either true
or false
.
Anyway, I solved my own problem. Thanks for your quick response.