diff --git a/actions.yml b/actions.yml index 6ef6985..880a21b 100644 --- a/actions.yml +++ b/actions.yml @@ -16,7 +16,6 @@ inputs: file_pattern: description: File pattern used for "git add" required: false - default: '.' runs: using: 'docker' diff --git a/entrypoint.sh b/entrypoint.sh index da2f1a2..4c012cb 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -18,6 +18,18 @@ EOF git config --global user.name "GitHub Actions" } +is_defined() { + [ ! -z "${1}" ] +} + +get_value() { + if is_defined "${1}"; then + return "${1}" + fi + + return "${2}" +} + # This section only runs if there have been file changes echo "Checking for uncommitted changes in the git working tree." @@ -30,15 +42,10 @@ then # Switch to branch from current Workflow run git checkout $INPUT_BRANCH - if [ -z ${INPUT_FILE_PATTERN+x} ]; - then - git add . - else - echo "INPUT_FILE_PATTERN value: $INPUT_FILE_PATTERN"; - git add $INPUT_FILE_PATTERN - fi + git add get_value "${INPUT_FILE_PATTERN}" '.' + + git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>" get_value "${INPUT_COMMIT_OPTIONS}" '' - git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>" $INPUT_COMMIT_OPTIONS git push --set-upstream origin "HEAD:$INPUT_BRANCH" else