🐛 Fix broken links #376
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Spellcheck Markdown | |
on: [push, pull_request] | |
jobs: | |
spellcheck: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install codespell | |
run: pip install codespell | |
- name: Filter files and run codespell | |
run: | | |
# Create a temporary file to store words to ignore | |
TEMP_IGNORE_FILE=$(mktemp) | |
# Ignore Acronyms (all caps), with and without trailing punctuation | |
grep --no-filename -oE '\b[A-Z]+\b' $(git ls-files '*.md') | sort -u >> $TEMP_IGNORE_FILE | |
# Ignore Proper nouns (capitalized first letter), with and without trailing punctuation | |
grep --no-filename -oE '\b[A-Z][a-z]+\b' $(git ls-files '*.md') | sort -u >> $TEMP_IGNORE_FILE | |
# Ignore words that start and end with . because they are likely to be in http links | |
# but only add their version without the . to the list | |
grep --no-filename -oE '\b\.[a-z]+\b' $(git ls-files '*.md') | sed 's/^.//' | sort -u >> $TEMP_IGNORE_FILE | |
# Remove duplicate entries | |
sort -u $TEMP_IGNORE_FILE -o $TEMP_IGNORE_FILE | |
# Cat ignore file for debugging | |
echo "Ignore list: $(tr '\n' ',' < $TEMP_IGNORE_FILE)" | |
# Run codespell on Markdown files with dynamically generated ignore list | |
codespell --ignore-words-list="$(tr '\n' ',' < $TEMP_IGNORE_FILE)" $(git ls-files '*.md') | |
# Clean up | |
rm $TEMP_IGNORE_FILE |