diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4a5b221..ac9c48e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,7 +43,7 @@ jobs: github_token: ${{ secrets.github_token }} reporter: github-pr-review level: error - fail_on_error: true + fail_level: any - name: check the exit code if: ${{ !success() }} run: echo 'The previous step should fail' && exit 1 diff --git a/README.md b/README.md index 8ba3765..8b9405c 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ This action runs [Linkspector](https://github.com/UmbrellaDocs/linkspector) with with: github_token: ${{ secrets.github_token }} reporter: github-pr-review - fail_on_error: true + fail_level: any ``` ## Action inputs @@ -58,9 +58,14 @@ For more details, see [Reporters](https://github.com/reviewdog/reviewdog?tab=rea For more details, please see [Filter mode support table](https://github.com/reviewdog/reviewdog?tab=readme-ov-file#filter-mode-support-table). +### `fail_level` + +(Optional) Exit code for reviewdog when errors are found with severity greater than or equal to the given level [none,any,info,warning,error]. +Default is `none`. + ### `fail_on_error` -(Optional) Exit code for reviewdog when errors are found [true,false] +(Optional, deprecated) Exit code for reviewdog when errors are found [true,false]. This option is ignored if `fail_level` is used. Default is `false`. ### `reviewdog_flags` diff --git a/action.yml b/action.yml index c20e9bb..567da17 100644 --- a/action.yml +++ b/action.yml @@ -23,9 +23,13 @@ inputs: Filtering mode for the reviewdog command [added,diff_context,file,nofilter]. Default is added. default: 'added' + fail_level: + Exit code for reviewdog when errors are found with severity greater than or equal to the given level [none,any,info,warning,error]. + Default is `none`. + default: '' fail_on_error: description: | - Exit code for reviewdog when errors are found [true,false]. + (Deprecated) Exit code for reviewdog when errors are found [true,false]. This option is ignored if `fail_level` is used. Default is `false`. default: 'false' reviewdog_flags: @@ -45,6 +49,18 @@ runs: - uses: reviewdog/action-setup@v1 with: reviewdog_version: v0.20.2 + - run: | + if [ -n "${INPUT_FAIL_LEVEL}" ]; then + echo "INPUT_FAIL_LEVEL=${INPUT_FAIL_LEVEL}" >> "${GITHUB_ENV}" + elif [ "${INPUT_FAIL_ON_ERROR}" = "true" ]; then + echo "INPUT_FAIL_LEVEL=any" >> "${GITHUB_ENV}" + else + echo "INPUT_FAIL_LEVEL=none" >> "${GITHUB_ENV}" + fi + shell: bash + env: + INPUT_FAIL_LEVEL: ${{ inputs.fail_level }} + INPUT_FAIL_ON_ERROR: ${{ inputs.fail_on_error }} - run: $GITHUB_ACTION_PATH/script.sh shell: bash env: @@ -54,7 +70,7 @@ runs: INPUT_LEVEL: ${{ inputs.level }} INPUT_REPORTER: ${{ inputs.reporter }} INPUT_FILTER_MODE: ${{ inputs.filter_mode }} - INPUT_FAIL_ON_ERROR: ${{ inputs.fail_on_error }} + INPUT_FAIL_LEVEL: ${{ env.INPUT_FAIL_LEVEL }} INPUT_REVIEWDOG_FLAGS: ${{ inputs.reviewdog_flags }} INPUT_CONFIG_FILE: ${{ inputs.config_file }} branding: diff --git a/script.sh b/script.sh index 8556fa5..8dc92b7 100755 --- a/script.sh +++ b/script.sh @@ -19,7 +19,7 @@ linkspector check -c "${INPUT_CONFIG_FILE}" -j | -name="${INPUT_TOOL_NAME}" \ -reporter="${INPUT_REPORTER}" \ -filter-mode="${INPUT_FILTER_MODE}" \ - -fail-on-error="${INPUT_FAIL_ON_ERROR}" \ + -fail-level="${INPUT_FAIL_LEVEL}" \ -level="${INPUT_LEVEL}" \ "${INPUT_REVIEWDOG_FLAGS}" exit_code=$?