-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
44 lines (39 loc) · 1.35 KB
/
delete-comments.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: Delete 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 = ['www.mediafire.com'];
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.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: commentId
});
- name: Block user from the org if their comment contained any of the banned strings
if: steps.check_comment.outputs.result == 'true'
uses: actions/github-script@v7
with:
script: |
const username = context.payload.comment.user.login
await github.rest.orgs.blockUser({
org: context.repo.owner,
username: username
});