diff --git a/.github/workflows/spelling-check-bot.yml b/.github/workflows/spelling-check-bot.yml index 9c1fd7b8fe64ff8..a81250fc2f262cb 100644 --- a/.github/workflows/spelling-check-bot.yml +++ b/.github/workflows/spelling-check-bot.yml @@ -24,25 +24,33 @@ jobs: npm install echo Running spelling check... output=$(npx cspell --no-progress --gitignore --config .vscode/cspell.json "**/*.md" || exit 0) + output=$(node scripts/linkify-logs.js "${output}") + output=$(echo "$output" | sed 's/^/- /') echo "$output" echo "OUTPUT<> $GITHUB_ENV echo "$output" >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV - - name: Create an issue + - name: Report spellcheck errors if: env.OUTPUT != '' - uses: dacbd/create-issue-action@main - with: - token: ${{ secrets.GITHUB_TOKEN }} - title: Weekly spelling check - body: | - Typos and unknown words: - - ``` - ${{ env.OUTPUT }} - ``` - - > [!TIP] - > To exclude words from the spellchecker, you can add valid words (web technology terms or abbreviations) to the [terms-abbreviations.txt](https://github.com/mdn/content/blob/main/.vscode/terms-abbreviations.txt) dictionary for IDE autocompletion. To ignore strings that are not words (`AABBCC` in code, for instance), you can add them to [ignore-list.txt](https://github.com/mdn/content/blob/main/.vscode/ignore-list.txt). + run: | + comment_body=$(cat< [!TIP] + > To exclude words from the spellchecker, you can add valid words (web technology terms or abbreviations) to the [terms-abbreviations.txt](https://github.com/mdn/content/blob/main/.vscode/terms-abbreviations.txt) dictionary for IDE autocompletion. To ignore strings that are not words (\`AABBCC\` in code, for instance), you can add them to [ignore-list.txt](https://github.com/mdn/content/blob/main/.vscode/ignore-list.txt). + EOM + ) + comment_body+=$'\n\n'$(echo "_(comment last updated: $(date +'%Y-%m-%d %H:%M:%S'))_") + gh api \ + --method PATCH \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/mdn/content/issues/35634 \ + -f "state=open" \ + -f "body=${comment_body}" env: OUTPUT: ${{ env.OUTPUT }} + GH_TOKEN: ${{ github.token }} diff --git a/scripts/linkify-logs.js b/scripts/linkify-logs.js new file mode 100644 index 000000000000000..a420f39ffd1437b --- /dev/null +++ b/scripts/linkify-logs.js @@ -0,0 +1,18 @@ +/* + * The script converts file paths to GitHub source links in the provided text. + * Usage: node scripts/linkify-logs.js ${logs} + */ + +const logs = process.argv[2]; + +console.log( + logs.replaceAll( + /(files\/.*?\/index.md):?(\d+)?:?(\d+)?/g, + (_, path, lineNo, columnNo) => { + if (lineNo) { + return `[${path}:${lineNo}:${columnNo}](https://github.com/mdn/content/blob/main/${path}?plain=1#L${lineNo})`; + } + return `[${path}](https://github.com/mdn/content/blob/main/${path}?plain=1)`; + }, + ), +);