Skip to content

Commit

Permalink
Merge pull request #57 from hpedrorodrigues/main
Browse files Browse the repository at this point in the history
Small fixes for branch dev
  • Loading branch information
creyD authored Sep 7, 2021
2 parents 67f2a40 + 6c9f8f1 commit c392c4f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
20 changes: 15 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c392c4f

Please sign in to comment.