diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b96e655..ee972dc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,5 +1,5 @@ on: pull_request - +name: CI jobs jobs: main: permissions: @@ -19,17 +19,12 @@ jobs: id: spell-check run: | status=0 - echo "### :warning: Spell check failed" > typos-output - uv run typos --format brief >> typos-output || status=$? - if [[ ${status} -ne 0 ]]; then - echo "failed=true" >> "${GITHUB_OUTPUT}" - exit 0 - fi - exit ${status} + echo "### :bulb: Spell check report" > spell_check_report.md + uv run typos --format brief >> spell_check_report.md || status=$? + exit 0 - - name: Spell check comment - uses: thollander/actions-comment-pull-request@v3 + - name: Save spell check report artifact + uses: actions/upload-artifact@v4 with: - comment-tag: spell-check-failed-comment - file-path: typos-output - mode: ${{ steps.spell-check.outputs.failed == 'true' && 'upsert' || 'delete' }} + name: Spell check report + path: spell_check_report.md diff --git a/.github/workflows/pr_comment.yml b/.github/workflows/pr_comment.yml new file mode 100644 index 0000000..5ec727e --- /dev/null +++ b/.github/workflows/pr_comment.yml @@ -0,0 +1,35 @@ +on: + workflow_run: + workflows: + - CI jobs + types: + - completed + +jobs: + spell-check-comment: + runs-on: ubuntu-latest + if: > + github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.conclusion == 'success' + steps: + - name: Download spell check report + uses: actions/download-artifact@v4 + with: + github-token: ${{ github.token }} + name: Spell check report + run-id: ${{ github.event.workflow_run.id }} + - name: Check if spell check failed + id: spell-check + run: | + lines=$(wc -l spell_check_report.md | cut -d ' ' -f1) + if [[ ${lines} -gt 1 ]]; then + echo "failed=true" >> "${GITHUB_OUTPUT}" + else + echo "failed=false" >> ${GITHUB_OUTPUT}" + fi + - name: Post spell check PR comment + uses: thollander/actions-comment-pull-request@v3 + with: + comment-tag: spell-check-failed + file-path: spell_check_report.md + mode: ${{ steps.spell-check.outputs.failed == 'true' && 'upsert' || 'delete' }}