From e61369fd7f2168121369bd03a28b53d250020c95 Mon Sep 17 00:00:00 2001 From: Tsuyoshi CHO Date: Tue, 12 May 2020 21:16:56 +0900 Subject: [PATCH] Use version and npx controll project or default or defined version textlint --- Dockerfile | 8 +------- README.md | 5 +++++ action.yml | 9 ++++----- entrypoint.sh | 23 ++++++++++++++++++----- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index f69a239..5ab74f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,12 +7,6 @@ RUN apk --update add git && \ rm -rf /var/lib/apt/lists/* && \ rm /var/cache/apk/* -WORKDIR / -ENV PATH $PATH:/node_modules/.bin -COPY package.json package-lock.json / -RUN npm ci --production - -COPY entrypoint.sh / -RUN chmod +x /entrypoint.sh +COPY entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index 79c3ad2..ea0d544 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,14 @@ github-pr-review can use Markdown and add a link to rule page in reviewdog repor textlint arguments (i.e. target dir:`doc/*`) +### `textlint_version` + +if textlint do not contain in project, use this version. + ## Customizes `.textlintrc` put in your repo. +And package.json that install textlint with plugins, in your repo. ## Example usage diff --git a/action.yml b/action.yml index 6abd3a0..1476431 100644 --- a/action.yml +++ b/action.yml @@ -20,14 +20,13 @@ inputs: description: "flags and args of textlint command. Default: '.'" default: '.' required: false + textlint_version: + description: "if textlint do not contain in project, use this version. default:'11.6.3'" + default: '11.6.3' + required: false runs: using: 'docker' image: 'Dockerfile' - args: - - ${{ inputs.github_token }} - - ${{ inputs.level }} - - ${{ inputs.reporter }} - - ${{ inputs.textlint_flags }} branding: icon: 'alert-octagon' color: 'blue' diff --git a/entrypoint.sh b/entrypoint.sh index 0d9ccc0..33e3cce 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,9 +4,22 @@ cd "$GITHUB_WORKSPACE" export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" -textlint --version +# nothing command, try project package install +if [ ! -f "$(npm bin)/textlint" ]; then + npm install +fi +# nothing command in after install, use command direct install +PACKAGE="" +if [ ! -f "$(npm bin)/textlint" ]; then + PACKAGE="-p textlint@${INPUT_TEXTLINT_VERSION:-11.6.3}" + echo textlint direct install version: ${INPUT_TEXTLINT_VERSION:-11.6.3} +else + npx textlint --version +fi -textlint -f checkstyle "${INPUT_TEXTLINT_FLAGS:-'.'}" \ - | reviewdog -f=checkstyle -name="textlint" \ - -reporter="${INPUT_REPORTER:-'github-pr-check'}" \ - -level="${INPUT_LEVEL:-'error'}" +npx ${PACKAGE} textlint -f checkstyle "${INPUT_TEXTLINT_FLAGS:-.}" \ + | reviewdog -f=checkstyle -name="textlint" \ + -reporter="${INPUT_REPORTER:-'github-pr-check'}" \ + -level="${INPUT_LEVEL:-'error'}" + +# EOF