Merge pull request #57 from hpedrorodrigues/main

Small fixes for branch dev
This commit is contained in:
2021-09-07 17:39:06 +02:00
committed by GitHub
2 changed files with 16 additions and 5 deletions

View File

@@ -66,6 +66,7 @@ runs:
INPUT_PRETTIER_VERSION: ${{ inputs.prettier_version }}
INPUT_ONLY_CHANGED: ${{ inputs.only_changed }}
INPUT_PRETTIER_PLUGINS: ${{ inputs.prettier_plugins }}
INPUT_GITHUB_TOKEN: ${{ inputs.github_token }}
branding:
icon: "award"

View File

@@ -2,7 +2,7 @@
# e is for exiting the script automatically if a command fails, u is for exiting if a variable is not set
# x would be for showing the commands before they are executed
set -eu
shopt -s globstar nullglob
shopt -s globstar
# FUNCTIONS
# Function for setting up git env in the docker container (copied from https://github.com/stefanzweifel/git-auto-commit-action/blob/master/entrypoint.sh)
@@ -63,11 +63,21 @@ fi
PRETTIER_RESULT=0
echo "Prettifying files..."
echo "Files:"
prettier $INPUT_PRETTIER_OPTIONS || { PRETTIER_RESULT=$?; echo "Problem running prettier with $INPUT_PRETTIER_OPTIONS"; }
prettier $INPUT_PRETTIER_OPTIONS \
|| { PRETTIER_RESULT=$?; echo "Problem running prettier with $INPUT_PRETTIER_OPTIONS"; exit 1; }
# Ignore node modules and other action created files
rm -r node_modules/ || echo "No node_modules/ folder."
git reset --hard package-lock.json || rm package-lock.json || echo "No package-lock.json file."
if [ -d 'node_modules' ]; then
rm -r node_modules/
else
echo "No node_modules/ folder."
fi
if [ -f 'package-lock.json' ]; then
git reset --hard package-lock.json || rm package-lock.json
else
echo "No package-lock.json file."
fi
# To keep runtime good, just continue if something was changed
if _git_changed; then
@@ -100,7 +110,7 @@ if _git_changed; then
git push origin -f
else
git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>" ${INPUT_COMMIT_OPTIONS:+"$INPUT_COMMIT_OPTIONS"} || echo "No files added to commit"
git push origin $INPUT_PUSH_OPTIONS
git push origin ${INPUT_PUSH_OPTIONS:-}
fi
echo "Changes pushed successfully."
fi