Skip to content

Commit

Permalink
Delete spam/malware comments automatically (#2199)
Browse files Browse the repository at this point in the history
  • Loading branch information
messense authored Aug 27, 2024
1 parent 2a16046 commit a40f720
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/delete-comments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Delete Spam Comments

on:
issue_comment:
types: [created]

permissions:
issues: write

jobs:
delete_comment:
runs-on: ubuntu-latest
steps:
- name: Check for specific strings in comment
id: check_comment
uses: actions/github-script@v7
with:
script: |
const comment = context.payload.comment.body;
const triggerStrings = ['mediafire.com', 'download'];
return triggerStrings.some(triggerString => comment.includes(triggerString));
- name: Delete comment if it contains any of the specific strings
if: steps.check_comment.outputs.result == 'true'
uses: actions/github-script@v7
with:
script: |
const commentId = context.payload.comment.id;
await github.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: commentId
});
- name: Block user if comment contains any of the specific strings
if: steps.check_comment.outputs.result == 'true'
uses: actions/github-script@v7
with:
script: |
const userId = context.payload.comment.user.id;
await github.users.block({
owner: context.repo.owner,
repo: context.repo.repo,
user_id: userId
});

0 comments on commit a40f720

Please sign in to comment.