Skip to content

Commit 424fdfa

Browse files
authored
Add delete comments workflow (#14439)
We are getting spam in the issues' comments. This should get rid of it. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/SeleniumHQ/selenium?shareId=XXXX-XXXX-XXXX-XXXX).
1 parent e2f6e14 commit 424fdfa

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

delete-comments.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Delete Comments
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
permissions:
8+
issues: write
9+
10+
jobs:
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@v6
17+
with:
18+
script: |
19+
const comment = context.payload.comment.body;
20+
const triggerStrings = ['www.mediafire.com', 'Download'];
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@v6
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@v6
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+
});

0 commit comments

Comments
 (0)