-
Notifications
You must be signed in to change notification settings - Fork 28
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
Use target_branches
to select target branches
#340
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
As we continue to expand the number of available inputs, it makes sense to order the inputs alphabetically. This allows users to more easily find the documentation for the input they're looking for. To help out with top-to-bottom readabability, we can use links in the descriptions. For example, in the how it works section we can link directly to the input's heading.
This note contained incorrect information. It is true that a workflow that runs in the `pull_request` context for a pull request from a forked repository does not have write access. It is also true that a PAT can be used to specify permissions. But, a PAT should be stored as a secret and secrets are not available to workflows running in the `pull_request` context for pull requests from a forked repository. So the proposed solution cannot work. We can simply remove the proposed alternative, since it is fine to run this workflow in the `pull_request_target`.
If we want to add an input that specifies target branches, then the structure of the code needs to be slightly different. Previously, the code would loop over each label and determine if a backport should happen for that label. Now, we want to loop over all target branches. This means that we have to find the target branches first, and then loop over them. This refactoring extracts this to a separate function, so it can be easily called and tested. It also determines the target branches before fetching all the commits from the pull request. This allows us to remove the check whether any of the labels matches the label pattern, because this allowed us to avoid unnecessarily fetching the commits if there were no targets found. We can now simply stop when there are no target branches found.
korthout
force-pushed
the
292-target-branches-input
branch
2 times, most recently
from
May 29, 2023 18:10
d3e6e2b
to
e271ac1
Compare
New input that allows specifying the target branches explicitly.
The method to find target branches required large objects as inputs, and it is part of the large Backport class. We can extract the core parts into a separate function and test that function.
This allows users to disable label matching explicitly by using an empty string as label_pattern. This is useful when users want to switch entirely to the target_branches input.
In order to only use the `target_branches` input, it can be useful to completely disable the `label_pattern` input. This adds the ability to completely disable determining the target branches based on labels. Simply set the `label_pattern` input to an empty string `''`.
Originally, I went for comma-separated values in the target_branches input. However, commas are a valid char in git branchnames. I think it makes more sense to delimit the values on spaces. Spaces are not allowed in branchnames.
korthout
force-pushed
the
292-target-branches-input
branch
from
May 29, 2023 18:14
e271ac1
to
9b43050
Compare
✅ Tested successfully here, using this workflow with 254871b. |
This was referenced May 29, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Until now, this action could only backport pull requests by selecting the target branches using labels. This pull request introduces a new input
target_branches
that can be used instead of the labels (or in addition to).For example, in your repo you want every pull request targeting a
release/*
branch to be forward-ported to your default branchmain
. With this pull request, this is now possible:resolves #292