From 5fc6f9f67570b6e23ed93a342e4ee4f97d8cbb99 Mon Sep 17 00:00:00 2001 From: Tsuyoshi CHO Date: Mon, 25 Jan 2021 19:51:10 +0900 Subject: [PATCH 1/7] first new action.yml --- action.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 436c226..4204e7f 100644 --- a/action.yml +++ b/action.yml @@ -36,8 +36,22 @@ inputs: description: 'Tool name to use for reviewdog reporter' default: 'textlint' runs: - using: 'docker' - image: 'Dockerfile' + using: 'composite' + steps: + - run: $GITHUB_ACTION_PATH/script.sh + shell: sh + env: + REVIEWDOG_VERSION: v0.11.0 + # INPUT_ is not available in Composite run steps + # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 + INPUT_GITHUB_TOKEN: ${{ inputs.github_token }} + INPUT_LEVEL: ${{ inputs.level }} + INPUT_REPORTER: ${{ inputs.reporter }} + INPUT_FILTER_MODE: ${{ inputs.filter_mode }} + INPUT_FAIL_ON_ERROR: ${{ inputs.fail_on_error }} + INPUT_REVIEWDOG_FLAGS: ${{ inputs.reviewdog_flags }} + INPUT_TEXTLINT_FLAGS: ${{ inputs.textlint_flags }} + INPUT_TOOL_NAME: ${{ inputs.tool_name }} branding: icon: 'alert-octagon' color: 'blue' From 56d7475642ad83073a0d55a628d70ed55752f92c Mon Sep 17 00:00:00 2001 From: Tsuyoshi CHO Date: Mon, 25 Jan 2021 19:51:29 +0900 Subject: [PATCH 2/7] rename script --- entrypoint.sh => script.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename entrypoint.sh => script.sh (100%) diff --git a/entrypoint.sh b/script.sh similarity index 100% rename from entrypoint.sh rename to script.sh From 9cbc32fab7300a8fc9fa7ec44827dbf861435ca4 Mon Sep 17 00:00:00 2001 From: Tsuyoshi CHO Date: Mon, 25 Jan 2021 19:59:17 +0900 Subject: [PATCH 3/7] renew script --- script.sh | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/script.sh b/script.sh index 49210a8..e55f83c 100755 --- a/script.sh +++ b/script.sh @@ -1,27 +1,37 @@ #!/bin/sh -set -e -if [ -n "${GITHUB_WORKSPACE}" ] ; then - cd "${GITHUB_WORKSPACE}" || exit -fi +# shellcheck disable=SC2086,SC2089,SC2090 -export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" +cd "${GITHUB_WORKSPACE}" || exit + +TEMP_PATH="$(mktemp -d)" +PATH="${TEMP_PATH}:$PATH" + +echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog' +curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b "${TEMP_PATH}" "${REVIEWDOG_VERSION}" 2>&1 +echo '::endgroup::' -# setup and check. +echo '::group:: Installing textlint ... https://github.com/textlint/textlint' if [ -x "./node_modules/.bin/textlint" ]; then # pass - : + echo '::group:: already installed' else + echo '::group:: npm ci start' npm ci fi if [ -x "./node_modules/.bin/textlint" ]; then npx textlint --version else - echo This repository was not configured for textlint, process done. + echo '::group:: This repository was not configured for textlint, process done.' exit 1 fi +echo '::endgroup::' + +export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" + +echo '::group:: Running textlint with reviewdog 🐶 ...' # shellcheck disable=SC2086 npx textlint -f checkstyle "${INPUT_TEXTLINT_FLAGS}" \ | reviewdog -f=checkstyle \ @@ -34,6 +44,7 @@ npx textlint -f checkstyle "${INPUT_TEXTLINT_FLAGS}" \ # github-pr-review only diff adding if [ "${INPUT_REPORTER}" = "github-pr-review" ]; then + echo '::group:: textlint fixing report' # fix npx textlint --fix "${INPUT_TEXTLINT_FLAGS:-.}" || true @@ -53,5 +64,6 @@ if [ "${INPUT_REPORTER}" = "github-pr-review" ]; then git restore . || true rm -f "${TMPFILE}" fi +echo '::endgroup::' # EOF From df033037b94dddd2e20f7f8b3ee9a2c61ce4c0cd Mon Sep 17 00:00:00 2001 From: Tsuyoshi CHO Date: Mon, 25 Jan 2021 20:12:29 +0900 Subject: [PATCH 4/7] remove docker build --- .github/workflows/dockerimage.yml | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 .github/workflows/dockerimage.yml diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml deleted file mode 100644 index f24f009..0000000 --- a/.github/workflows/dockerimage.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Docker Image CI -on: - push: - branches: - - master - pull_request: -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: true - - name: Build the Docker image - run: docker build . --file Dockerfile --tag ${{ github.repository }}:$(date +%s) From 91eb5fbe150de0792c14ee268e22824966574999 Mon Sep 17 00:00:00 2001 From: Tsuyoshi CHO Date: Mon, 25 Jan 2021 20:24:02 +0900 Subject: [PATCH 5/7] remove dockerfile --- Dockerfile | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 9322b28..0000000 --- a/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM node:15.6.0-alpine - -# reviewdog -ENV REVIEWDOG_VERSION=v0.11.0 - -# hadolint ignore=DL3006 -RUN apk --no-cache add git - -RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION} - -COPY entrypoint.sh /entrypoint.sh - -ENTRYPOINT ["/entrypoint.sh"] From 428557a6cb5b8b6530a7b9f6d070ba96f43eccef Mon Sep 17 00:00:00 2001 From: Tsuyoshi CHO Date: Mon, 25 Jan 2021 20:27:44 +0900 Subject: [PATCH 6/7] cleanup script --- script.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/script.sh b/script.sh index e55f83c..8c9a7fb 100755 --- a/script.sh +++ b/script.sh @@ -13,17 +13,16 @@ echo '::endgroup::' echo '::group:: Installing textlint ... https://github.com/textlint/textlint' if [ -x "./node_modules/.bin/textlint" ]; then - # pass - echo '::group:: already installed' + echo 'already installed' else - echo '::group:: npm ci start' + echo 'npm ci start' npm ci fi if [ -x "./node_modules/.bin/textlint" ]; then npx textlint --version else - echo '::group:: This repository was not configured for textlint, process done.' + echo 'This repository was not configured for textlint, process done.' exit 1 fi echo '::endgroup::' @@ -41,10 +40,11 @@ npx textlint -f checkstyle "${INPUT_TEXTLINT_FLAGS}" \ -fail-on-error="${INPUT_FAIL_ON_ERROR}" \ -level="${INPUT_LEVEL}" \ ${INPUT_REVIEWDOG_FLAGS} +echo '::endgroup::' # github-pr-review only diff adding if [ "${INPUT_REPORTER}" = "github-pr-review" ]; then - echo '::group:: textlint fixing report' + echo '::group:: Running textlint fixing report 🐶 ...' # fix npx textlint --fix "${INPUT_TEXTLINT_FLAGS:-.}" || true @@ -63,7 +63,7 @@ if [ "${INPUT_REPORTER}" = "github-pr-review" ]; then git restore . || true rm -f "${TMPFILE}" + echo '::endgroup::' fi -echo '::endgroup::' # EOF From e001ace4798b92f28baab0f0b3cc30de28b3dc84 Mon Sep 17 00:00:00 2001 From: Tsuyoshi CHO Date: Mon, 25 Jan 2021 20:44:23 +0900 Subject: [PATCH 7/7] Update README --- README.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3202234..25a9e7b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ action-textlint use textlint within npm ecosystem. ## detail -[![Docker Image CI](https://github.com/tsuyoshicho/action-textlint/workflows/Docker%20Image%20CI/badge.svg)](https://github.com/tsuyoshicho/action-textlint/actions) [![Release](https://github.com/tsuyoshicho/action-textlint/workflows/release/badge.svg)](https://github.com/tsuyoshicho/action-textlint/releases) This action runs [textlint](https://github.com/textlint/textlint) with @@ -18,6 +17,14 @@ based on [reviewdog/action-vint](https://github.com/reviewdog/action-vint) [![github-pr-check example](https://user-images.githubusercontent.com/96727/70858620-bdc2fb80-1f48-11ea-9c1a-b5abb5a6566a.png)](https://user-images.githubusercontent.com/96727/70858620-bdc2fb80-1f48-11ea-9c1a-b5abb5a6566a.png) [![github-pr-review example](https://user-images.githubusercontent.com/96727/70858610-a1bf5a00-1f48-11ea-84c4-7ee7392548e6.png)](https://user-images.githubusercontent.com/96727/70858610-a1bf5a00-1f48-11ea-84c4-7ee7392548e6.png) +Notice: +This action is `composition action`. It need `npm ci`. + +You accept below one: + +- Your workflow manually setup to run `npm ci`. +- This action automatic run `npm ci`. + ## Inputs ### `github_token` @@ -81,19 +88,19 @@ jobs: with: node-version: '15' - name: textlint-github-pr-check - uses: tsuyoshicho/action-textlint@v2 + uses: tsuyoshicho/action-textlint@v3 with: github_token: ${{ secrets.github_token }} reporter: github-pr-check textlint_flags: "doc/**" - name: textlint-github-check - uses: tsuyoshicho/action-textlint@v2 + uses: tsuyoshicho/action-textlint@v3 with: github_token: ${{ secrets.github_token }} reporter: github-check textlint_flags: "doc/**" - name: textlint-github-pr-review - uses: tsuyoshicho/action-textlint@v2 + uses: tsuyoshicho/action-textlint@v3 with: github_token: ${{ secrets.github_token }} reporter: github-pr-review