|
| 1 | +name: Monitor Abusive Comments |
| 2 | +on: |
| 3 | + issue_comment: |
| 4 | + # This shouldn't be called for comment deletion |
| 5 | + types: |
| 6 | + - created |
| 7 | + - edited |
| 8 | + |
| 9 | +jobs: |
| 10 | + abuse-monitor: |
| 11 | + name: With latest code base |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Handle with Comvent |
| 16 | + |
| 17 | + id: comvent |
| 18 | + with: |
| 19 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 20 | + config-path: .github/config/comvent-ad.yaml |
| 21 | + |
| 22 | + # The below only runs when comvent finds matching comment. |
| 23 | + # This assumes that comvent config holding 'some-abusive-content' as a keyword. |
| 24 | + - if: steps.comvent.outputs.blocked-words != '' |
| 25 | + name: Handle some abusive content |
| 26 | + uses: actions/github-script@v3 |
| 27 | + with: |
| 28 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 29 | + # An example of removing the abusive comment, and leaving a comment about the deletion. |
| 30 | + script: | |
| 31 | + github.issues.deleteComment({ |
| 32 | + owner: context.repo.owner, |
| 33 | + repo: context.repo.repo, |
| 34 | + comment_id: ${{ github.event.comment.id }} |
| 35 | + }) |
| 36 | + const comment = `Found blocked words! 😰 |
| 37 | + The comment was thus removed.`; |
| 38 | + github.issues.createComment({ |
| 39 | + issue_number: context.issue.number, |
| 40 | + owner: context.repo.owner, |
| 41 | + repo: context.repo.repo, |
| 42 | + body: comment |
| 43 | + }) |
0 commit comments