From 5c365ab3fa00072450bddc018c60fc181d133e6d Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 18:10:42 +0100 Subject: [PATCH] Another bugfix attempt trying to generate the global flag only if needed --- Dockerfile | 4 ---- action.yml | 1 + entrypoint.sh | 14 +++++++++----- 3 files changed, 10 insertions(+), 9 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index cfd542a..0000000 --- a/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM node:lts-alpine3.9 -RUN apk update && apk add --no-cache bash git openssh -COPY entrypoint.sh /entrypoint.sh -ENTRYPOINT ["/entrypoint.sh"] diff --git a/action.yml b/action.yml index b23b101..3a70533 100644 --- a/action.yml +++ b/action.yml @@ -56,6 +56,7 @@ runs: INPUT_PRETTIER_VERSION: ${{ inputs.prettier_version }} INPUT_ONLY_CHANGED: ${{ inputs.only_changed }} INPUT_PRETTIER_PLUGINS: ${{ inputs.prettier_plugins }} + PATH: $(cd $GITHUB_ACTION_PATH; npm bin):$PATH branding: icon: "award" diff --git a/entrypoint.sh b/entrypoint.sh index a463036..a5b1b55 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/bash # 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 +set -eux # 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) @@ -25,16 +25,20 @@ _git_changed() { [[ -n "$(git status -s)" ]] } -( +if [ -n "$GITHUB_ACTION_PATH" ]; then + INPUT_IS_GLOBAL='' +else + INPUT_IS_GLOBAL=--global +fi # PROGRAM echo "Installing prettier..." case $INPUT_PRETTIER_VERSION in false) - npm install --silent prettier + npm install --silent $INPUT_IS_GLOBAL prettier ;; *) - npm install --silent prettier@$INPUT_PRETTIER_VERSION + npm install --silent $INPUT_IS_GLOBAL prettier@$INPUT_PRETTIER_VERSION ;; esac @@ -48,7 +52,7 @@ if [ -n "$INPUT_PRETTIER_PLUGINS" ]; then exit 1 fi done - npm install --silent $INPUT_PRETTIER_PLUGINS + npm install --silent $INPUT_IS_GLOBAL $INPUT_PRETTIER_PLUGINS fi )