diff --git a/Dockerfile b/Dockerfile index 4ae548f..8e0a3a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20-slim +FROM node:18-slim LABEL version="1.0.0" LABEL repository="http://github.com/Github-Actions-Community/merge-release" @@ -12,14 +12,12 @@ LABEL com.github.actions.color="red" RUN apt-get -y update && \ apt-get -y --no-install-recommends install git jq findutils curl ca-certificates && \ - rm -rf /var/lib/apt/lists/* && \ - npm update -g npm + rm -rf /var/lib/apt/lists/* -WORKDIR /usr/app -COPY ./ ./ +COPY . . # Install dependencies here RUN npm ci --omit dev -ENTRYPOINT ["/usr/app/entrypoint.sh"] +ENTRYPOINT ["/entrypoint.sh"] CMD ["help"] diff --git a/entrypoint.sh b/entrypoint.sh index faefc69..6fcf641 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,21 +3,21 @@ set -e # Map the inputs over to the environment variables to support both `env` and `with` methods for backwards-compatibility -export DEBUG=${INPUT_DEBUG:-"$DEBUG"} -export DEPLOY_DIR=${INPUT_DEPLOY_DIR:-"$DEPLOY_DIR"} -export DISABLE_GIT_TAG=${INPUT_DISABLE_GIT_TAG:-"$DISABLE_GIT_TAG"} -export GIT_TAG_SUFFIX=${INPUT_GIT_TAG_SUFFIX:-"$GIT_TAG_SUFFIX"} -export GITHUB_ACTOR=${INPUT_GITHUB_ACTOR:-"$GITHUB_ACTOR"} -export GITHUB_REPOSITORY=${INPUT_GITHUB_REPOSITORY:-"$GITHUB_REPOSITORY"} -export GITHUB_TOKEN=${INPUT_GITHUB_TOKEN:-"$GITHUB_TOKEN"} -export MAJOR_TAGS=${INPUT_MAJOR_TAGS:-"$MAJOR_TAGS"} -export MINOR_TAGS=${INPUT_MINOR_TAGS:-"$MINOR_TAGS"} -export NPM_AUTH_TOKEN=${INPUT_NPM_AUTH_TOKEN:-"$NPM_AUTH_TOKEN"} -export NPM_CONFIG_USERCONFIG=${INPUT_NPM_CONFIG_USERCONFIG:-"$NPM_CONFIG_USERCONFIG"} -export NPM_CUSTOM_NPMRC=${INPUT_NPM_CUSTOM_NPMRC:-"$NPM_CUSTOM_NPMRC"} -export NPM_PRIVATE=${INPUT_NPM_PRIVATE:-"$NPM_PRIVATE"} -export NPM_REGISTRY_URL=${INPUT_NPM_REGISTRY_URL:-"$NPM_REGISTRY_URL"} -export SRC_PACKAGE_DIR=${INPUT_SRC_PACKAGE_DIR:-"$SRC_PACKAGE_DIR"} +export DEBUG="${INPUT_DEBUG:-"$DEBUG"}" +export DEPLOY_DIR="${INPUT_DEPLOY_DIR:-"$DEPLOY_DIR"}" +export DISABLE_GIT_TAG="${INPUT_DISABLE_GIT_TAG:-"$DISABLE_GIT_TAG"}" +export GIT_TAG_SUFFIX="${INPUT_GIT_TAG_SUFFIX:-"$GIT_TAG_SUFFIX"}" +export GITHUB_ACTOR="${INPUT_GITHUB_ACTOR:-"$GITHUB_ACTOR"}" +export GITHUB_REPOSITORY="${INPUT_GITHUB_REPOSITORY:-"$GITHUB_REPOSITORY"}" +export GITHUB_TOKEN="${INPUT_GITHUB_TOKEN:-"$GITHUB_TOKEN"}" +export MAJOR_TAGS="${INPUT_MAJOR_TAGS:-"$MAJOR_TAGS"}" +export MINOR_TAGS="${INPUT_MINOR_TAGS:-"$MINOR_TAGS"}" +export NPM_AUTH_TOKEN="${INPUT_NPM_AUTH_TOKEN:-"$NPM_AUTH_TOKEN"}" +export NPM_CONFIG_USERCONFIG="${INPUT_NPM_CONFIG_USERCONFIG:-"$NPM_CONFIG_USERCONFIG"}" +export NPM_CUSTOM_NPMRC="${INPUT_NPM_CUSTOM_NPMRC:-"$NPM_CUSTOM_NPMRC"}" +export NPM_PRIVATE="${INPUT_NPM_PRIVATE:-"$NPM_PRIVATE"}" +export NPM_REGISTRY_URL="${INPUT_NPM_REGISTRY_URL:-"$NPM_REGISTRY_URL"}" +export SRC_PACKAGE_DIR="${INPUT_SRC_PACKAGE_DIR:-"$SRC_PACKAGE_DIR"}" # Set default values NPM_STRICT_SSL="${NPM_STRICT_SSL-true}" @@ -26,10 +26,10 @@ if ! $NPM_STRICT_SSL; then NPM_REGISTRY_SCHEME="http" fi NPM_REGISTRY_URL="${NPM_REGISTRY_SCHEME}://"$(echo "${NPM_REGISTRY_URL:-registry.npmjs.org}" | sed -r 's/https?:\/\///') -MINOR_TAGS=${MINOR_TAGS:-"feat"} -DEPLOY_DIR=${DEPLOY_DIR:-"."} -SRC_PACKAGE_DIR=${SRC_PACKAGE_DIR:-"."} -NPM_CONFIG_USERCONFIG=${NPM_CONFIG_USERCONFIG:-"$HOME/.npmrc"} +MINOR_TAGS="${MINOR_TAGS:-"feat"}" +DEPLOY_DIR="${DEPLOY_DIR:-"."}" +SRC_PACKAGE_DIR="${SRC_PACKAGE_DIR:-"."}" +NPM_CONFIG_USERCONFIG="${NPM_CONFIG_USERCONFIG:-"$HOME/.npmrc"}" if [ "$DEBUG" = "true" ]; then echo "Debug Enabled, Printing Environment:" @@ -40,13 +40,13 @@ fi if [ -n "$NPM_CUSTOM_NPMRC" ]; then # Use a fully-formed npmrc file if provided echo "$NPM_CUSTOM_NPMRC" > "$NPM_CONFIG_USERCONFIG" + chmod 0600 "$NPM_CONFIG_USERCONFIG" elif [ -n "$NPM_AUTH_TOKEN" ]; then # Allow registry.npmjs.org to be overridden with an environment variable printf "//%s/:_authToken=%s\\nregistry=%s\\nstrict-ssl=%s" "$NPM_REGISTRY_URL" "$NPM_AUTH_TOKEN" "$NPM_REGISTRY_URL" "${NPM_STRICT_SSL}" > "$NPM_CONFIG_USERCONFIG" + chmod 0600 "$NPM_CONFIG_USERCONFIG" fi -chmod 0600 "$NPM_CONFIG_USERCONFIG" - if [ "$DEBUG" = "true" ]; then echo "Debug Enabled, Printing '$NPM_CONFIG_USERCONFIG' file contents:" cat "$NPM_CONFIG_USERCONFIG" @@ -65,4 +65,4 @@ git show-ref # useful for debugging git branch --verbose # Dependencies are installed at build time -node /usr/app/src/merge-release-run.js "$@" || exit 1 +node /src/merge-release-run.js "$@" || exit 1 diff --git a/src/merge-release-run.js b/src/merge-release-run.js index 63cd8db..33e8d6d 100644 --- a/src/merge-release-run.js +++ b/src/merge-release-run.js @@ -186,7 +186,7 @@ const run = async () => { console.log(' New Version:', newVersion); - if (pkg.scripts && pkg.scripts.publish) { + if (pkg?.scripts?.publish) { spawnSync(`npm run publish`, deployDir); } else { const verbose = debug ? ' --verbose' : '';