From da21c6b08d651331559f3a6cd427bfffc663c528 Mon Sep 17 00:00:00 2001 From: Carles Pina i Estany Date: Wed, 4 Nov 2020 15:02:44 +0000 Subject: [PATCH] set options to make it easier to debug if a command fails Make use of optional arguments on action.yml in order to avoid testing against an undefined variable --- action.yml | 4 +++- entrypoint.sh | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index b3e65ef..387dd0f 100644 --- a/action.yml +++ b/action.yml @@ -16,8 +16,10 @@ inputs: destination-repository-username: description: '[Optional] Username/organization for the destination repository' required: false + default: '' target-branch: - description: '[Optional] set target branch name for the destination repository' + description: '[Optional] set target branch name for the destination repository. Defaults to "master"' + default: 'master' required: false runs: using: 'docker' diff --git a/entrypoint.sh b/entrypoint.sh index ea93e63..4d6aec6 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,10 @@ #!/bin/sh -l + + +set -e # if a command fails it stops the execution +set -u # script fails if trying to access to an undefined variable + echo "Starts" FOLDER="$1" GITHUB_USERNAME="$2" @@ -12,10 +17,6 @@ if [ -z "$REPO_USERNAME" ] then REPO_USERNAME="$GITHUB_USERNAME" fi -if [ -z "$TARGET_BRANCH" ] -then - TARGET_BRANCH="master" -fi CLONE_DIR=$(mktemp -d)