Skip to content

Commit

Permalink
Create new branch if NAME is given
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanzweifel committed Feb 7, 2021
1 parent 8056699 commit 53438d5
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,40 @@ _switch_to_branch() {
git fetch --depth=1;
fi

# Switch to branch from current Workflow run
# shellcheck disable=SC2086
git checkout $INPUT_BRANCH;



# If INPUT_BRANCH is empty, just run `git checkout`
if [ -z "$INPUT_BRANCH" ]
then

# Switch to branch from current Workflow run
# shellcheck disable=SC2086
git checkout $INPUT_BRANCH;

else

# If INPUT_BRANCH is given, check if a branch already exists
# If not create one


if [ -n "$(git branch | grep $INPUT_BRANCH)" ]
then

# Switch to branch from current Workflow run
# shellcheck disable=SC2086
git checkout $INPUT_BRANCH;

else

# Switch to branch from current Workflow run
# shellcheck disable=SC2086
git checkout -b $INPUT_BRANCH;

fi

fi

}

_add_files() {
Expand Down

0 comments on commit 53438d5

Please sign in to comment.