Files
Dominic Evans cdc57b28e8 chore(ci): correct github-script API calls (#14442)
* chore(ci): correct github-script API calls

Since V5 of github-script the Octokit context available via `github` no
longer has REST methods directly on it, they were moved to
`github.rest.*` instead. Update the references in delete-comments.yml
job to match.

Signed-off-by: Dominic Evans <dominic.evans@uk.ibm.com>

* fix(ci): remove 'Download' from delete-comments

This is too generic a word and frequently matches against comments that
don't need to be deleted, nor should the user be blocked as the current
workflow will do.

Signed-off-by: Dominic Evans <dominic.evans@uk.ibm.com>

* fix(ci): correct block user task

The existing code was calling the individual "block a user" REST
endpoint with incorrect parameters and never would have worked. Update
it to (presumably achieve the desired outcome) block the user from the
owning organisation instead.

Signed-off-by: Dominic Evans <dominic.evans@uk.ibm.com>

---------

Signed-off-by: Dominic Evans <dominic.evans@uk.ibm.com>
2024-08-28 10:13:58 +02:00

45 lines
1.3 KiB
YAML

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
});