Don't require two separate labels
Krzmbrzl opened this issue · 7 comments
As far as I understand, we currently have to add a lable auto-backport
and another label auto-backport-to-xyz
in order to have a given PR backported.
This seems like seemingly unneeded duplication information. At least from the user's perspective, it should be enough to have the auto-backport-to-xyz
label as this already indicates the desire to have this PR automatically backported.
However, I suspect this is a limitation/complication of being able to search for prefixes (substrings) in the label texts? Aka: with this line in the example config:
contains(github.event.pull_request.labels.*.name, 'auto-backport')
However, it would be a neat feature if we would not require this duplication :)
Based on the docs for expressions in GA, it seems like something like this should almost do the work for checking for a prefix:
contains(join(github.event.pull_request.labels.*.name, '-;-'), '-;-auto-backport')
However, this would fail if the respective label is the only label on that PR or the label is first in the label array for different reasons (as in this case it won't be prefixed with the separator). Maybe something can be built on this to make it work...
One possibility that should work would be to use a second join and a temporary array:
contains(join(['', join(github.event.pull_request.labels.*.name, '-;-')], '-;-'), '-;-auto-backport')
but at this point it really becomes unreadable...
@Krzmbrzl just wondering what would happen if one always trigger the action, but the second label is not present? If the action then would just silently return a "skipped" status it should work with just one label but maybe run the action a bit more often than required.
Hm. That is a good question, but I don't actually know 🤔
And my TypeScript-Fu is too weak to quickly skim the code to figure it out xD
@sqren maybe you could give some insights into what happens when the branchLabel
is not present (or the provided Regex doesn't match any label)?
I believe that this code
https://github.com/sqren/backport-github-action/blob/e325a2d70df7264afa24c92b1d5feb2278ff63af/src/run.ts#L26-L29
indicates that there seems to be some kind of handling for this case, doesn't it?
Hm. That is a good question, but I don't actually know thinking
You can try it out live :-)
Hi there,
Sorry for the late reply!
Two separate labels are not required. You will just need to remove the if
statement from .github/workflows/backport.yml
. I have updated the example in the readme so it now simply looks like this:
on:
pull_request_target:
types: ["labeled", "closed"]
jobs:
backport:
name: Backport PR
runs-on: ubuntu-latest
steps:
- name: Backport Action
uses: sqren/backport-github-action@v9.2.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
auto_backport_label_prefix: auto-backport-to-
This way you simply need to add a single label like auto-backport-to-production
to backport to "production" branch.
I'll close this issue but please don't hesitate to reach our if you have any questions
That's great - thanks 👍