name: "Check for typos in the source tree"

permissions: read-all

on:
  pull_request:
  workflow_dispatch:
  push:

jobs:
  check-typos:
    runs-on: ubuntu-latest
    if: "!contains(github.event.pull_request.title, '[skip ci]')"
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Check for typos
        uses: crate-ci/typos@master
        with:
          config: .github/typos.toml

      - name: Fail Gracefully
        if: ${{ failure() }}
        shell: bash
        run: |
          echo "::error:: Current codebase contains typos that were caught by the CI!"
          echo "If those typos were intentional, please add them to the ignored regexes in .github/typos.toml"
          echo "[skip ci] label may be used if this is a one-time issue"
          exit 1