diff --git a/Dockerfile b/Dockerfile index 6c96f60..5a02118 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,8 @@ COPY LICENSE \ requirements.txt \ /code/ +RUN apk add --no-cache bash + RUN pip install -r /code/requirements.txt ENTRYPOINT ["/code/entrypoint.sh"] diff --git a/README.md b/README.md index df04849..e016cf9 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,43 @@ Any warnings or errors will be annotated in the Pull Request. uses: codespell-project/actions-codespell@master ``` +## Possible use for checking a pull request +``` +# GitHub Action to automate the identification of common misspellings in text files. +# https://github.com/codespell-project/actions-codespell +# https://github.com/codespell-project/codespell + +name: Codespell +on: + pull_request_target: + +jobs: + codespell: + name: Check for spelling errors + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v12.2 + + - name: Get the latest dictionary + run: | + wget https://raw.githubusercontent.com/codespell-project/codespell/master/codespell_lib/data/dictionary.txt + + - name: Get the latest rare dictionary + run: | + wget https://raw.githubusercontent.com/codespell-project/codespell/master/codespell_lib/data/dictionary_rare.txt + + - uses: codespell-project/actions-codespell@master + with: + dictionary: dictionary.txt,dictionary_rare.txt + path: ${{ steps.changed-files.outputs.all_changed_files }} +``` + + + ### Parameter: check_filenames If set, check file names for spelling mistakes as well. @@ -57,6 +94,17 @@ with: skip: foo,bar ``` +### Parameter: dictionary + +Comma-separated list of custom dictionaries to use. +This parameter is optional; by default `codespell` will use the builtin dictionaries. + +``` +uses: codespell-project/actions-codespell@master +with: + dictionary: dictionary.txt,dictionary2.txt +``` + ### Parameter: builtin Comma-separated list of builtin dictionaries to use. diff --git a/action.yml b/action.yml index 522d9cf..029d35b 100644 --- a/action.yml +++ b/action.yml @@ -18,6 +18,10 @@ inputs: description: 'Comma-separated list of files to skip (it accepts globs as well)' required: false default: './.git' + dictionary: + description: 'Comma-separated list of custom dictionary files that contains spelling corrections.' + required: false + default: '' builtin: description: 'Comma-separated list of builtin dictionaries to include' required: false diff --git a/entrypoint.sh b/entrypoint.sh index 0fc188f..177555d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Copy the matcher to the host system; otherwise "add-matcher" can't find it. cp /code/codespell-matcher.json /github/workflow/codespell-matcher.json @@ -28,6 +28,13 @@ echo "Skipping '${INPUT_SKIP}'" if [ "x${INPUT_SKIP}" != "x" ]; then command_args="${command_args} --skip ${INPUT_SKIP}" fi +echo "Custom dictionary '${INPUT_DICTIONARY}'" +if [ "x${INPUT_DICTIONARY}" != "x" ]; then + IFS=',' read -ra DICTIONARY <<< "${INPUT_DICTIONARY}" + for i in "${DICTIONARY[@]}"; do + command_args="${command_args} --dictionary $i" + done +fi echo "Builtin dictionaries '${INPUT_BUILTIN}'" if [ "x${INPUT_BUILTIN}" != "x" ]; then command_args="${command_args} --builtin ${INPUT_BUILTIN}"