Skip to content

Commit

Permalink
Creating orphan branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Daishan committed Sep 2, 2020
1 parent 303ce37 commit 505389d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

set -eu
set -x

_main() {
_switch_to_repository
Expand Down Expand Up @@ -39,8 +40,13 @@ _git_is_dirty() {
_switch_to_branch() {
echo "INPUT_BRANCH value: $INPUT_BRANCH";

# Switch to branch from current Workflow run
git checkout $INPUT_BRANCH;
if git show-ref --verify --quiet refs/heads/$INPUT_BRANCH; then
# Switch to branch from current Workflow run
git checkout $INPUT_BRANCH;
else
git checkout --orphan $INPUT_BRANCH
git rm -rf .
fi
}

_add_files() {
Expand Down

0 comments on commit 505389d

Please # to comment.