Merge pull request #14 from creyD/dev

Removed branch parameter + Bugfix for prettier_version
This commit is contained in:
2020-05-04 13:51:51 +02:00
committed by GitHub
2 changed files with 9 additions and 21 deletions

View File

@@ -19,9 +19,6 @@ inputs:
description: Options for the `prettier` command description: Options for the `prettier` command
required: false required: false
default: '--write **/*.js' default: '--write **/*.js'
branch:
description: Target branch for the changes
required: true
dry: dry:
description: Running the script in dry mode just shows whether there are files that should be prettified or not description: Running the script in dry mode just shows whether there are files that should be prettified or not
required: false required: false

View File

@@ -25,23 +25,16 @@ _git_changed() {
[[ -n "$(git status -s)" ]] [[ -n "$(git status -s)" ]]
} }
# Pushes to the according upstream (origin or input branch)
_git_push() {
if [ -z "$INPUT_BRANCH" ]
then
git push origin
else
git push --set-upstream origin "HEAD:$INPUT_BRANCH"
fi
}
# PROGRAM # PROGRAM
echo "Installing prettier..." echo "Installing prettier..."
if "$INPUT_PRETTIER_VERSION"; then case $INPUT_PRETTIER_VERSION in
npm install --silent --global prettier@$INPUT_PRETTIER_VERSION false)
else npm install --silent --global prettier
npm install --silent --global prettier ;;
fi *)
npm install --silent --global prettier@$INPUT_PRETTIER_VERSION
;;
esac
echo "Prettifing files..." echo "Prettifing files..."
echo "Files:" echo "Files:"
@@ -57,13 +50,11 @@ then
# Calling method to configure the git environemnt # Calling method to configure the git environemnt
_git_setup _git_setup
echo "Commiting and pushing changes..." echo "Commiting and pushing changes..."
# Switch to the actual branch
git checkout $INPUT_BRANCH || echo "Problem checking out the specified branch: $INPUT_BRANCH"
# Add changes to git # Add changes to git
git add "${INPUT_FILE_PATTERN}" || echo "Problem adding your files with pattern ${INPUT_FILE_PATTERN}" git add "${INPUT_FILE_PATTERN}" || echo "Problem adding your files with pattern ${INPUT_FILE_PATTERN}"
# Commit and push changes back # Commit and push changes back
git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>" ${INPUT_COMMIT_OPTIONS:+"$INPUT_COMMIT_OPTIONS"} git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>" ${INPUT_COMMIT_OPTIONS:+"$INPUT_COMMIT_OPTIONS"}
_git_push git push origin
echo "Changes pushed successfully." echo "Changes pushed successfully."
fi fi
else else