mirror of
https://github.com/stefanzweifel/git-auto-commit-action.git
synced 2025-07-31 06:57:40 +08:00
Add create_branch
option to force create a new branch (#203)
* Add create_branch option * Checkout new branch if create_branch input is true * Add tests * Update README
This commit is contained in:
@@ -48,19 +48,25 @@ _switch_to_branch() {
|
||||
echo "INPUT_BRANCH value: $INPUT_BRANCH";
|
||||
|
||||
# Fetch remote to make sure that repo can be switched to the right branch.
|
||||
|
||||
if "$INPUT_SKIP_FETCH"; then
|
||||
echo "::debug::git-fetch has not been executed";
|
||||
else
|
||||
git fetch --depth=1;
|
||||
fi
|
||||
|
||||
# If `skip_checkout`-input is true, skip the entire checkout step.
|
||||
if "$INPUT_SKIP_CHECKOUT"; then
|
||||
echo "::debug::git-checkout has not been executed";
|
||||
else
|
||||
# Switch to branch from current Workflow run
|
||||
# shellcheck disable=SC2086
|
||||
git checkout $INPUT_BRANCH --;
|
||||
# Create new local branch if `create_branch`-input is true
|
||||
if "$INPUT_CREATE_BRANCH"; then
|
||||
# shellcheck disable=SC2086
|
||||
git checkout -B $INPUT_BRANCH --;
|
||||
else
|
||||
# Switch to branch from current Workflow run
|
||||
# shellcheck disable=SC2086
|
||||
git checkout $INPUT_BRANCH --;
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user