delete-comments.yml

 1name: Delete Mediafire Comments
 2
 3on:
 4  issue_comment:
 5    types: [created]
 6
 7permissions:
 8  issues: write
 9
10jobs:
11  delete_comment:
12    runs-on: ubuntu-latest
13    steps:
14      - name: Check for specific strings in comment
15        id: check_comment
16        uses: actions/github-script@v7
17        with:
18          script: |
19            const comment = context.payload.comment.body;
20            const triggerStrings = ['www.mediafire.com', 'Download', 'changeme'];
21            return triggerStrings.some(triggerString => comment.includes(triggerString));
22
23      - name: Delete comment if it contains any of the specific strings
24        if: steps.check_comment.outputs.result == 'true'
25        uses: actions/github-script@v7
26        with:
27          script: |
28            const commentId = context.payload.comment.id;
29            await github.issues.deleteComment({
30              owner: context.repo.owner,
31              repo: context.repo.repo,
32              comment_id: commentId
33            });
34
35      - name: Block user if comment contains any of the specific strings
36        if: steps.check_comment.outputs.result == 'true'
37        uses: actions/github-script@v7
38        with:
39          script: |
40            const userId = context.payload.comment.user.id;
41            await github.users.block({
42              owner: context.repo.owner,
43              repo: context.repo.repo,
44              user_id: userId
45            });