Repository navigation
a11y: Label the code-block copy button #410
Workflow file for this run
This file contains hidden or 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: Spell check | |
| # Reports spelling errors on lines added by a pull request, as a summary comment | |
| # plus inline review comments on the flagged lines. Existing spelling errors and | |
| # errors on unchanged lines are not included. The pull request's title and | |
| # description are checked too, and reported in the summary comment. | |
| on: | |
| pull_request: | |
| # `edited` fires when the title or description changes | |
| types: [opened, synchronize, reopened, edited] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| spellcheck: | |
| name: CSpell (advisory) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out pull request head | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| fetch-depth: 0 | |
| # Node 24 is pre-cached on ubuntu-latest, avoiding the download | |
| # incurred by node-version: latest. | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| # Install only CSpell instead of the site's full dependency tree. | |
| - name: Install CSpell | |
| run: npm install --global cspell@10 | |
| - name: Find spelling errors introduced by this PR | |
| id: check | |
| # Title and description come in through env, never inline in the | |
| # script, so a crafted pull request cannot inject shell commands | |
| env: | |
| BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| PR_TITLE: ${{ github.event.pull_request.title }} | |
| PR_BODY: ${{ github.event.pull_request.body }} | |
| run: | | |
| base=$(git merge-base "$BASE_SHA" HEAD) | |
| printf '%s\n\n%s\n' "$PR_TITLE" "$PR_BODY" > "$RUNNER_TEMP/pull-request.md" | |
| # The script exits 1 both with findings and when it crashes at import | |
| # time. It writes its output in one go at the end, so a crash leaves | |
| # it empty. A crash does not fail the check, since it says nothing | |
| # about the PR; the report step says so instead of posting the | |
| # empty report | |
| node dev/check-spelling.mjs --base "$base" \ | |
| --pull-request "$RUNNER_TEMP/pull-request.md" --format json \ | |
| > "$RUNNER_TEMP/spelling.json" || true | |
| if ! [ -s "$RUNNER_TEMP/spelling.json" ]; then | |
| echo "::warning::check-spelling crashed, so this PR was not checked" | |
| echo "crashed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| cat "$RUNNER_TEMP/spelling.json" | |
| - name: Report on the pull request | |
| # Fork PRs get a read-only token; the findings are still in the job log | |
| if: github.event.pull_request.head.repo.full_name == github.repository | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| HEAD_REF: ${{ github.event.pull_request.head.ref }} | |
| RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
| CRASHED: ${{ steps.check.outputs.crashed }} | |
| run: | | |
| if [ "$CRASHED" = true ]; then | |
| node dev/post-spelling-review.mjs --crashed | |
| else | |
| node dev/post-spelling-review.mjs --findings "$RUNNER_TEMP/spelling.json" | |
| fi |