From dc4245256a0f54fb1cf5a694b441618d03ad8f81 Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev <33040934+AlexJameson@users.noreply.github.com> Date: Thu, 22 Aug 2024 17:47:32 +0300 Subject: [PATCH] add comments correctly --- .github/workflows/spellcheck-ru.yml | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/spellcheck-ru.yml b/.github/workflows/spellcheck-ru.yml index f41cacdfb11..9dc53dd9652 100644 --- a/.github/workflows/spellcheck-ru.yml +++ b/.github/workflows/spellcheck-ru.yml @@ -32,13 +32,35 @@ jobs: echo "::set-output name=all_files::$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | tr '\n' ' ')" - name: Run CSpell on all changed files + id: cspell_check continue-on-error: true run: | + output="" for file in ${{ steps.files.outputs.all_files }}; do if [ "$file" = ".github/workflows/spellcheck-ru.yml" ] || [ "$file" = "cspell.json" ]; then echo "Skipping CSpell check for $file" continue fi echo "Checking $file for spelling errors..." - cspell $file --config cspell.json --show-suggestions - done \ No newline at end of file + result=$(cspell "$file" --config cspell.json) + if [ -n "$result" ]; then + output+="### Errors in $file:\n\\\\n$result\n\\\\n\n" + fi + done + echo "::set-output name=results::${output}" + + - name: Post results as a PR comment + if: steps.cspell_check.outputs.results != '' + uses: actions/github-script@v5 + with: + script: | + const output = ${{ steps.cspell_check.outputs.results }}; + const prNumber = context.payload.pull_request.number; + const repoName = context.repo.repo; + const ownerName = context.repo.owner; + github.rest.issues.createComment({ + owner: ownerName, + repo: repoName, + issue_number: prNumber, + body: output + }); \ No newline at end of file