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) 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"] 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 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' diff --git a/entrypoint.sh b/script.sh similarity index 63% rename from entrypoint.sh rename to script.sh index 49210a8..8c9a7fb 100755 --- a/entrypoint.sh +++ b/script.sh @@ -1,27 +1,36 @@ #!/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 'already installed' else + echo '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 '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 \ @@ -31,9 +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:: Running textlint fixing report 🐶 ...' # fix npx textlint --fix "${INPUT_TEXTLINT_FLAGS:-.}" || true @@ -52,6 +63,7 @@ if [ "${INPUT_REPORTER}" = "github-pr-review" ]; then git restore . || true rm -f "${TMPFILE}" + echo '::endgroup::' fi # EOF