Fix delete comments workflow (#16896)

Release Notes:

- N/A
This commit is contained in:
jvmncs
2024-08-26 12:54:52 -04:00
committed by GitHub
parent d50cb17256
commit e8c6c537de
+44
View File
@@ -0,0 +1,44 @@
name: Delete Mediafire 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', 'Download', 'changeme'];
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 if comment contains any of the specific 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
});