Skip to content

Commit

Permalink
chore(ci): correct github-script API calls (#14442)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
dnwe committed Aug 28, 2024
1 parent 85f589e commit cdc57b2
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/delete-comments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
script: |
const comment = context.payload.comment.body;
const triggerStrings = ['www.mediafire.com', 'Download'];
const triggerStrings = ['www.mediafire.com'];
return triggerStrings.some(triggerString => comment.includes(triggerString));
- name: Delete comment if it contains any of the specific strings
Expand All @@ -26,20 +26,19 @@ jobs:
with:
script: |
const commentId = context.payload.comment.id;
await github.issues.deleteComment({
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
- 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 userId = context.payload.comment.user.id;
await github.users.block({
owner: context.repo.owner,
repo: context.repo.repo,
user_id: userId
const username = context.payload.comment.user.login
await github.rest.orgs.blockUser({
org: context.repo.owner,
username: username
});

0 comments on commit cdc57b2

Please sign in to comment.