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

Retrieve target branch from PR label(s) #75

Closed
1 task done
lampajr opened this issue Aug 1, 2023 · 2 comments · Fixed by #112
Closed
1 task done

Retrieve target branch from PR label(s) #75

lampajr opened this issue Aug 1, 2023 · 2 comments · Fixed by #112
Assignees
Labels
enhancement New feature or request

Comments

@lampajr
Copy link
Member

lampajr commented Aug 1, 2023

There are use cases where the target branch is not always fixed, instead it is dynamically computed from the original PR label(s).
That is why we created this additional workflow step [1] to properly parse labels with a prefixed pattern and extracting the target branch from them, this could be hard to maintain and error-prone.

Proposal: integrate this step in the tool itself, in this way target-branch will become optional and you can provide the regex/pattern to use in order to extract the target branch from the original PR labels, if any.

[1] https://github.com/kiegroup/droolsjbpm-build-bootstrap/blob/main/.github/workflows/pr-backporting.yml#L12-L25

Tasks

  1. enhancement
    lampajr
@lampajr lampajr added the enhancement New feature or request label Aug 1, 2023
@lampajr lampajr self-assigned this Aug 1, 2023
@earl-warren
Copy link
Contributor

here is a snippet for inspiration, from a similar action:

const getBaseBranches = ({
  labelRegExp,
  payload,
}: Readonly<{
  labelRegExp: RegExp;
  payload: PullRequestClosedEvent | PullRequestLabeledEvent;
}>): string[] => {
  if ("label" in payload) {
    const base = getBaseBranchFromLabel(payload.label.name, labelRegExp);
    return base ? [base] : [];
  }

  return compact(
    payload.pull_request.labels.map((label) =>
      getBaseBranchFromLabel(label.name, labelRegExp),
    ),
  );
};

@lampajr
Copy link
Member Author

lampajr commented Mar 23, 2024

That's a good hint, thanks @earl-warren for the reference!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants