From ff2bedbf19130221ba4f1de9bbff7ef61259b89e Mon Sep 17 00:00:00 2001 From: Prabhat Sharma Date: Tue, 27 Aug 2024 05:30:34 -0700 Subject: [PATCH] chore: Delete spam issue comments containing mediafire (#4349) Delete spam comments containing "mediafire" ## Summary by CodeRabbit - **New Features** - Introduced an automated workflow to identify and delete spam comments containing "Mediafire" in issue threads, enhancing the cleanliness of discussions. --- .github/workflows/spam-cleaner.yml | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/spam-cleaner.yml diff --git a/.github/workflows/spam-cleaner.yml b/.github/workflows/spam-cleaner.yml new file mode 100644 index 0000000000..c938adbc11 --- /dev/null +++ b/.github/workflows/spam-cleaner.yml @@ -0,0 +1,31 @@ +name: Delete Spam Comments + +on: + issue_comment: + types: [created, edited] + +jobs: + delete_mediafire_comments: + runs-on: ubuntu-latest + steps: + - name: Check for Mediafire in comments + uses: actions/github-script@v6 + with: + private-key: ${{ secrets.PRIVATE_KEY }} + # Set the owner, so the token can be used in all repositories + owner: ${{ github.repository_owner }} + script: | + const commentBody = context.payload.comment.body.toLowerCase(); + const commentId = context.payload.comment.id; + const issueNumber = context.payload.issue.number; + + if (commentBody.includes('mediafire')) { + console.log(`Deleting comment #${commentId} on issue #${issueNumber}`); + await github.rest.issues.deleteComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: commentId + }); + } else { + console.log('No Mediafire link found, no action needed.'); + }