Skip to content

Commit

Permalink
Merge pull request #47 from tsuyoshicho/feature/opt-update
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuyoshicho authored Oct 30, 2020
2 parents 037158a + d9ce602 commit 62e50d7
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 25 deletions.
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ based on [reviewdog/action-vint](https://github.com/reviewdog/action-vint)

### `github_token`

**Required**. Must be in form of `github_token: ${{ secrets.github_token }}`'.
**Required**. Default is `${{ github.token }}`.

### `level`

Expand All @@ -29,23 +29,40 @@ It's same as `-level` flag of reviewdog.
### `reporter`

Reporter of reviewdog command [github-pr-check,github-check,github-pr-review].
Default is github-pr-check.
Default is github-pr-review.
It's same as `-reporter` flag of reviewdog.

github-pr-review can use Markdown and add a link to rule page in reviewdog reports.

### `filter_mode`

Optional. Filtering mode for the reviewdog command [added,diff_context,file,nofilter].
Default is added.

### `fail_on_error`

Optional. Exit code for reviewdog when errors are found [true,false]
Default is `false`.

### `reviewdog_flags`

Optional. Additional reviewdog flags

### `basedir`

redpen target document base directory (i.e. `doc`)
Default: `.`.

### `targets`

redpen target file glob (i.e. `*.md`)
Search recursively.
Default: `*`.

### `config`

redpen config file path (i.e. `config/redpen-conf-en.xml`)
Default: `` (use redpen default rule).

## Example usage

Expand Down
42 changes: 25 additions & 17 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,47 @@ inputs:
github_token:
description: 'GITHUB_TOKEN.'
required: true
default: ${{ github.token }}
level:
description: 'Report level for reviewdog [info,warning,error]'
default: 'error'
required: false
reporter:
description: |
Reporter of reviewdog command [github-pr-check,github-pr-review].
Default is github-pr-check.
Reporter of reviewdog command [github-check,github-pr-review].
Default is github-pr-review.
github-pr-review can use Markdown and add a link to rule page in reviewdog reports.
default: 'github-pr-check'
required: false
default: 'github-pr-review'
filter_mode:
description: |
Filtering mode for the reviewdog command [added,diff_context,file,nofilter].
Default is added.
default: 'added'
fail_on_error:
description: |
Exit code for reviewdog when errors are found [true,false]
Default is `false`.
default: 'false'
reviewdog_flags:
description: 'Additional reviewdog flags'
default: ''
basedir:
description: "document basedir. Default: '.'"
required: true
default: '.'
required: false
targets:
description: "document files. Default: '*'"
required: true
default: '*'
required: false
config:
description: "config file path. Default(inner value): 'config/redpen-conf-en.xml'"
default: 'config/redpen-conf-en.xml'
required: false
description: "config file path. Default(use redpen default rule): ''"
required: true
default: ''
tool_name:
description: 'Tool name to use for reviewdog reporter'
default: 'redpen'
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.github_token }}
- ${{ inputs.level }}
- ${{ inputs.reporter }}
- ${{ inputs.basedir }}
- ${{ inputs.targets }}
- ${{ inputs.config }}
branding:
icon: 'alert-octagon'
color: 'blue'
17 changes: 11 additions & 6 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"

redpen --version

find "${INPUT_BASEDIR:-'.'}" -type f -name "${INPUT_TARGETS:-'*'}" -print0 \
| xargs -I {} -0 redpen -c "${INPUT_CONFIG:-'config/redpen-conf-en.xml'}" \
-l 9999 -r plain {} 2>/dev/null \
| reviewdog -efm="%f:%l: %m" -name="redpen" \
-reporter="${INPUT_REPORTER:-'github-pr-check'}" \
-level="${INPUT_LEVEL:-'error'}"
REDPEN_CONFIG=${INPUT_CONFIG+-c ${INPUT_CONFIG}}

find "${INPUT_BASEDIR}" -type f -name "${INPUT_TARGETS}" -print0 \
| xargs -I {} -0 redpen ${REDPEN_CONFIG} -l 9999 -r plain {} 2>/dev/null \
| reviewdog -efm="%f:%l: Validation%t%*[a-z]%m at line:%.\*" \
-name="${INPUT_TOOL_NAME}" \
-reporter="${INPUT_REPORTER:-github-pr-review}" \
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
-level="${INPUT_LEVEL}" \
${INPUT_REVIEWDOG_FLAGS}

0 comments on commit 62e50d7

Please sign in to comment.