From 505389d146760a6e0721ff81fd856b583d5ad84e Mon Sep 17 00:00:00 2001 From: Daishan Date: Tue, 1 Sep 2020 16:47:27 -0700 Subject: [PATCH] Creating orphan branch --- entrypoint.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index f51521a..cf10652 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,7 @@ #!/bin/bash set -eu +set -x _main() { _switch_to_repository @@ -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() {