diff --git a/README.md b/README.md index ecbfdbd..ab0fb41 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ Available options (with default value): repo_branch: 'master' # Branch of Standard repository phpcs_bin_path: 'phpcs' # Custom PHPCS bin path use_local_config: 'false' # Use local config if available + extra_args: '' # Extra arguments passing to the command ``` ## Examples @@ -77,6 +78,30 @@ jobs: with: standard: 'WordPress-VIP-Go' ``` +### Display the linting result in the GitHub Actions summary + +```yaml +name: WPCS check + +on: pull_request + +jobs: + phpcs: + name: VIPCS + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: VIPCS check + uses: 10up/wpcs-action@stable + with: + standard: 'WordPress-VIP-Go' + extra_args: '--report-json=./phpcs.json' + - name: Update summary + run: | + npx --yes github:10up/phpcs-json-to-md --path ./phpcs.json --output ./phpcs.md + cat phpcs.md >> $GITHUB_STEP_SUMMARY + if: always() +``` ## Support Level diff --git a/action.yml b/action.yml index 281eed9..a0a306e 100644 --- a/action.yml +++ b/action.yml @@ -34,6 +34,10 @@ inputs: description: 'Use local config if available' required: false default: 'false' + extra_args: + description: 'Passing extra arguments to the phpcs command' + required: false + default: '' runs: using: 'docker' image: 'Dockerfile' diff --git a/entrypoint.sh b/entrypoint.sh index 8998eeb..71e1d88 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -43,9 +43,9 @@ else fi if [ "${HAS_CONFIG}" = true ] && [ "${INPUT_USE_LOCAL_CONFIG}" = "true" ] ; then - ${INPUT_PHPCS_BIN_PATH} ${WARNING_FLAG} --report=checkstyle + ${INPUT_PHPCS_BIN_PATH} ${WARNING_FLAG} --report=checkstyle ${INPUT_EXTRA_ARGS} else - ${INPUT_PHPCS_BIN_PATH} ${WARNING_FLAG} --report=checkstyle --standard=${INPUT_STANDARD} --ignore=${EXCLUDES} --extensions=php ${INPUT_PATHS} + ${INPUT_PHPCS_BIN_PATH} ${WARNING_FLAG} --report=checkstyle --standard=${INPUT_STANDARD} --ignore=${EXCLUDES} --extensions=php ${INPUT_PATHS} ${INPUT_EXTRA_ARGS} fi status=$?