From cdc57b28e8759307476ab6ddd3492c50d7b75825 Mon Sep 17 00:00:00 2001 From: Dominic Evans <8060970+dnwe@users.noreply.github.com> Date: Wed, 28 Aug 2024 09:13:58 +0100 Subject: [PATCH] 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> --- .github/workflows/delete-comments.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/delete-comments.yml b/.github/workflows/delete-comments.yml index e5319d0725622..d766665ced333 100644 --- a/.github/workflows/delete-comments.yml +++ b/.github/workflows/delete-comments.yml @@ -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 @@ -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 });