Skip to content

Commit

Permalink
Add is_defined and get_value to improve on code's reusability
Browse files Browse the repository at this point in the history
  • Loading branch information
gomorizsolt committed Oct 31, 2019
1 parent a65a3a4 commit b6dcf94
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
1 change: 0 additions & 1 deletion actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ inputs:
file_pattern:
description: File pattern used for "git add"
required: false
default: '.'

runs:
using: 'docker'
Expand Down
23 changes: 15 additions & 8 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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
Expand Down

0 comments on commit b6dcf94

Please sign in to comment.