Skip to content

Create an issue to report typos #61

Create an issue to report typos

Create an issue to report typos #61

name: Create an issue to report typos
on:
schedule:
- cron: "0 0 * * mon"
workflow_dispatch:
permissions:
# Create issue.
issues: write
jobs:
sync:
if: github.repository == 'mdn/content'
runs-on: ubuntu-latest
permissions:
issues: write
timeout-minutes: 5
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Setup Node.js environment
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version-file: ".nvmrc"
package-manager-cache: false
- name: Install all yarn packages
run: yarn --frozen-lockfile
env:
# https://github.com/microsoft/vscode-ripgrep#github-api-limit-note
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run scripts
id: check
run: |
echo Running spelling check...
output=$(yarn --silent lint:typos-group-by-file || exit 0)
if [ -n "${output}" ]; then
output=$(node scripts/linkify-logs.js "${output}")
output=$(echo "$output" | sed 's/^/- /')
echo "Log size is ${#output} characters"
echo "$output"
# Trim output to avoid GraphQL 'Body is too long (maximum is 65536 characters)' error
maxLength=64000
if [ ${#output} -gt ${maxLength} ]; then
output=$(echo "$output" | head -c $maxLength)
output+=$'\n...\n\n> [!WARNING]\n> The report is too long to be posted in full. Check the complete report in the [workflow logs](https://github.com/mdn/content/actions/runs/'"${GITHUB_RUN_ID}"$').'
fi
echo "OUTPUT<<EOF" >> "$GITHUB_OUTPUT"
echo "$output" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
else
echo "No typos found! 🎉"
fi
- name: Report spellcheck errors
if: steps.check.outputs.OUTPUT != ''
run: |
issue=$(gh issue create --title "$TITLE" --label "$LABELS" --body "$BODY")
echo Issue URL ${issue}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TITLE: Weekly spelling check
LABELS: reported by automation
BODY: |
Typos and unknown words:
${{ steps.check.outputs.OUTPUT }}
> [!TIP]
> If the word is actually valid or it is required to be ignored, consider adding it to one of the dictionaries under [`.vscode/dictionaries`](https://github.com/mdn/content/tree/main/.vscode/dictionaries).