Skip to content

Commit

Permalink
Merge pull request #123 from tsuyoshicho/feature/gha-composition
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuyoshicho authored Jan 25, 2021
2 parents 59452e7 + e001ace commit 3f4d0b9
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 44 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/dockerimage.yml

This file was deleted.

13 changes: 0 additions & 13 deletions Dockerfile

This file was deleted.

15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`
Expand Down Expand Up @@ -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
Expand Down
18 changes: 16 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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_<VARIABLE_NAME> 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'
30 changes: 21 additions & 9 deletions entrypoint.sh → script.sh
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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

Expand All @@ -52,6 +63,7 @@ if [ "${INPUT_REPORTER}" = "github-pr-review" ]; then

git restore . || true
rm -f "${TMPFILE}"
echo '::endgroup::'
fi

# EOF

0 comments on commit 3f4d0b9

Please sign in to comment.