From 865a51b5807c3666695bb4f1d2c0c022211839e9 Mon Sep 17 00:00:00 2001 From: GuillaumeFalourd Date: Thu, 6 Jan 2022 22:30:25 -0300 Subject: [PATCH] update git push to remote action Signed-off-by: GuillaumeFalourd --- action.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index c858e21..ee33527 100644 --- a/action.yml +++ b/action.yml @@ -138,11 +138,13 @@ runs: REMOTE_URL=https://$DESTINATION_OWNER:${{ inputs.access_token }}@github.com/$DESTINATION_OWNER/$DESTINATION_REPOSITORY git remote set-url origin $REMOTE_URL git fetch origin - git ls-remote --heads origin ${{ inputs.target_branch }} | wc -l - if [ "$?" != "1" ]; then + BE=$(git ls-remote --heads origin ${{ inputs.target_branch }} | wc -l) + if [[ $BE == *"0"* ]]; then + echo "##### Target branch doesn't exist. Creating new branch #####" git checkout -b ${{ inputs.target_branch }} + else + git checkout ${{ inputs.target_branch }} fi - git checkout ${{ inputs.target_branch }} git add . git status