Check for typos #11
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: Check for typos | |
on: | |
workflow_dispatch: | |
jobs: | |
typos: | |
name: Typos | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
- name: Install typos binary | |
run: cargo +stable install typos-cli | |
- name: Check typos and write suggestions | |
id: typo-check | |
run: | | |
typos --write-changes > _typos.txt | |
if [[ `git status --porcelain --untracked-files=no` ]]; then | |
echo "typos=true" | tee -a $GITHUB_OUTPUT | |
else | |
echo "typos=false" | tee -a $GITHUB_OUTPUT | |
fi | |
- name: Create file for PR | |
if: steps.typo-check.outputs.typos == 'true' | |
run: | | |
printf '%s\n' "Fixes typos found by running \`typos --write-changes\` | |
Commit: ${{ github.sha }} | |
Workflow run: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" > _body.md | |
if [[ -s _typos.txt ]]; then | |
printf "The following typos could not be fixed:\n\`\`\`\n" >> _body.md | |
cat _typos.txt >> _body.md | |
printf "\`\`\`" >> _body.md | |
fi | |
# Note: Doesn't work for `push` or `pull_request` triggers | |
- name: Create pull request | |
uses: peter-evans/create-pull-request@v5 | |
if: steps.typo-check.outputs.typos == 'true' | |
with: | |
commit-message: '[automated] Fix typos' | |
title: '[automated] Fix typos' | |
body-path: ./_body.md | |
labels: automated issue, documentation |