Skip to content

Commit

Permalink
workflows: split PR comment to separate workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
airwoodix committed Nov 29, 2024
1 parent 050d25d commit b84d5fe
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 13 deletions.
21 changes: 8 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
on: pull_request

name: CI jobs
jobs:
main:
permissions:
Expand All @@ -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
35 changes: 35 additions & 0 deletions .github/workflows/pr_comment.yml
Original file line number Diff line number Diff line change
@@ -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' }}

0 comments on commit b84d5fe

Please sign in to comment.