mirror of
https://github.com/stefanzweifel/git-auto-commit-action.git
synced 2024-12-06 02:09:04 +00:00
Add is_defined and get_value to improve on code's reusability
This commit is contained in:
parent
a65a3a47cd
commit
b6dcf94303
@ -16,7 +16,6 @@ inputs:
|
||||
file_pattern:
|
||||
description: File pattern used for "git add"
|
||||
required: false
|
||||
default: '.'
|
||||
|
||||
runs:
|
||||
using: 'docker'
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user