generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Update Base Branch Improvements #237
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
divz44
previously approved these changes
Jan 30, 2024
cwage
approved these changes
Feb 1, 2024
ghost
reviewed
Feb 1, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch on scenarios 3 & 4 and the distinction between default_branch vs strict, that's an element of this I had not thought about! I'm a fan of strict
being the default here 🎉
Thanks so much for the quick turnaround here! This is an awesome improvement.
This was referenced Feb 1, 2024
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.
Update Base Branch Improvements
v9.0.0
It should be noted that this change is only "breaking" in the sense that unexpected behavior may take place for teams using more unique git flows for development. If you want to maintain the current state of this Action on
v9.0.0
and beyond, all you need to do is to simply setoutdated_mode: "pr_base"
in the Action configuration. This will keep the current logic of this Action where only thepr_base
is evaluated for "out-of-date-ness".This pull request updates the language around updating branches in this Action to make it more clear what is happening to the user.
It also adds a new input option called
outdated_mode
.Here is the full (very verbose) documentation to this new input option:
The
outdated_mode
input option gives you the ability to determine how the branch-deploy Action should handle outdated branches. This input option is closely related to theupdate_branch
input option as well.Using the
outdated_mode
input optionThe
outdated_mode
input option has three possible values:strict
(default): The branch-deploy Action will consider your branch (that you are deploying) to be out-of-date if it is behind the default|stable branch (i.emain
) or if it is behind the branch that your pull request is merging into.pr_base
: The branch-deploy Action will consider your branch (that you are deploying) to be out-of-date if it is behind the branch that your pull request is merging into.default_branch
: The branch-deploy Action will consider your branch (that you are deploying) to be out-of-date if it is behind the default|stable branch (i.emain
). Thedefault_branch
is determined by the value you have set for thestable_branch
input option. By default, the value of thestable_branch
input option ismain
.How the
outdated_mode
input option works with theupdate_branch
input optionIf your branch is determined to be out-of-date, the branch-deploy Action will not deploy your branch. What happens next is determined by the value of the
update_branch
input option. Here are the three possible values for theupdate_branch
input option and how they will operate:warn
: The branch-deploy Action will leave a comment on your pull request indicating that your branch is out-of-date and that you should update it before it can be deployed.force
: The branch-deploy Action will attempt to update your branch by merging the latest commits into your branch for you. You will need to re-run the deployment command after the branch-deploy Action has attempted to update your branch.disabled
: The branch-deploy Action will allow you to deploy your branch even if it is out-of-date. (dangerous)It should be noted that if you are using the
force
value for theupdate_branch
input option, the branch-deploy Action will only attempt to update your branch with the target base branch of the pull request. This means that if your target base branch is something other than the default|stable branch, the branch-deploy Action will only attempt to update your branch with the latest commits from the target base branch. You will still be warned about your branch being out-of-date with the default|stable branch but it will not try to update your branch with the latest commits from the default|stable branch due to the complexity and potential risk involved with such a merge. You will need to manually update your branch with the latest commits from the default|stable branch if you want to deploy your branch and that is the case.The final bit of important information to note is that rollback deployments (i.e
.deploy main
) will always work even if the default|stable branch is considered out-of-date. This is for safety reasons so that users of this Action can always rollback their changes in the event of an issue.About the
outdated_mode
input optionThe
outdated_mode
input option is useful when you want to ensure that the branch-deploy Action only deploys branches that are up-to-date. This is especially useful when you have a large team of developers working on a project and you want to ensure that commits are not rolled back accidentally when you are deploying a branch. For the sake of availability and deployment confidence, this input option is set tostrict
by default. This will ensure that your branch is up-to-date with the latest commits from both the default|stable branch and the branch that your pull request is merging into.Example Scenarios
This section will go into a few example scenarios to help you understand how the
outdated_mode
input option works in practice.For all scenarios, we assume that we are operating on a pull request that is at branch
featureB
(commitfeatB2
) in the diagram. The target base branch of the pull request isfeatureA
and the default|stable branch ismain
.Scenario 1
This example diagram shows a scenario where a branch is created from the default|stable branch (
main
in this case). The name of this branch isfeatureA
and a following branch is created fromfeatureA
calledfeatureB
. A few commits are made to thefeatureB
branch and sometime later, another developer merges two commits intomain
. ThefeatureB
branch is now out-of-date withmain
even though it is up-to-date with thefeatureA
branch. In this example, the target base branch offeatureB
isfeatureA
.Let's pretend that we are trying to run the
.deploy
command on the pull request associated withfeatureB
(which is trying to merge intofeatureA
).outdated_mode
input option is set tostrict
, the branch-deploy Action will consider thefeatureB
branch to be out-of-date and prevent the deployment from happening. This is because thefeatureB
branch is behind themain
branch. If this branch were to be deployed, it would roll back the commits made tomain
and that could cause issues. Even though thefeatureB
branch is up-to-date with thefeatureA
branch, it is still considered out-of-date because it is behind themain
branch when theoutdated_mode
input option is set tostrict
.outdated_mode
input option is set topr_base
, the branch-deploy Action will consider thefeatureB
branch to be up-to-date and allow the deployment to happen. This is because thefeatureB
branch is up-to-date with thefeatureA
branch. ThefeatureB
branch is behind themain
branch but that is not relevant in this case because the target base branch of the pull request isfeatureA
and notmain
.outdated_mode
input option is set todefault_branch
, the branch-deploy Action will consider thefeatureB
branch to be out-of-date and prevent the deployment from happening. This is because thefeatureB
branch is behind themain
branch. If this branch were to be deployed, it would roll back the commits made tomain
and that could cause issues. Even though thefeatureB
branch is up-to-date with thefeatureA
branch, it is still considered out-of-date because it is behind themain
branch when theoutdated_mode
input option is set todefault_branch
.Scenario 2
This scenario shows the "ideal" situation for a successful deployment. In this example, the
featureB
branch is up-to-date with both thefeatureA
branch and themain
branch. When this is the case, it does not matter which value you have set for theoutdated_mode
input option. Whether you have it set tostrict
,pr_base
, ordefault_branch
, all options in this case are up-to-date and the branch-deploy Action will allow the deployment to happen. Hooray!This diagram expands upon Scenario 1 and shows the
featureB
branch being updated by havingmain
merged into it:Alternatively, you could rebase the stack with
featureA
andfeatureB
on top ofmain
:Scenario 3
In this scenario, the branch
featureB
is now out-of-date in all cases. This is because thefeatureB
branch is behind both thefeatureA
branch and themain
branch. This is the worst-case scenario and the branch-deploy Action will prevent the deployment from happening in all cases. It does not matter what value you have set for theoutdated_mode
input option. Whether you have it set tostrict
,pr_base
, ordefault_branch
, all options in this case are out-of-date and the branch-deploy Action will prevent the deployment from happening.Scenario 4
In this example, the
featureB
branch is behindfeatureA
but up-to-date withmain
. In this case, theoutdated_mode
input option will determine whether the branch-deploy Action will allow the deployment to happen or not.outdated_mode
input option is set tostrict
(default), the branch-deploy Action will consider thefeatureB
branch to be out-of-date and prevent the deployment from happening. This is because thefeatureB
branch is behind thefeatureA
branch. Even though thefeatureB
branch is up-to-date with themain
branch, it is still considered out-of-date because it is behind thefeatureA
branch when theoutdated_mode
input option is set tostrict
so both the target base branch (of the pull request) and the default|stable branch are considered.outdated_mode
input option is set topr_base
, the branch-deploy Action will consider thefeatureB
branch to be out-of-date and prevent the deployment from happening. This is because thefeatureB
branch is behind thefeatureA
branch. In this case, the default|stable branch is not considered, only the target base branch (of the pull request) is considered.outdated_mode
input option is set todefault_branch
, the branch-deploy Action will consider thefeatureB
branch to be up-to-date and allow the deployment to happen. This is because thefeatureB
branch is up-to-date with themain
branch. Even though thefeatureB
branch is behind thefeatureA
branch, that is not relevant in this case becausedefault_branch
option only evaluates the default|stable branch.related: #235