Skip to content

Commit cdc57b2

Browse files
authored
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 <[email protected]> * 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 <[email protected]> * 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 <[email protected]> --------- Signed-off-by: Dominic Evans <[email protected]>
1 parent 85f589e commit cdc57b2

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

.github/workflows/delete-comments.yml

+7-8
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
with:
1818
script: |
1919
const comment = context.payload.comment.body;
20-
const triggerStrings = ['www.mediafire.com', 'Download'];
20+
const triggerStrings = ['www.mediafire.com'];
2121
return triggerStrings.some(triggerString => comment.includes(triggerString));
2222
2323
- name: Delete comment if it contains any of the specific strings
@@ -26,20 +26,19 @@ jobs:
2626
with:
2727
script: |
2828
const commentId = context.payload.comment.id;
29-
await github.issues.deleteComment({
29+
await github.rest.issues.deleteComment({
3030
owner: context.repo.owner,
3131
repo: context.repo.repo,
3232
comment_id: commentId
3333
});
3434
35-
- name: Block user if comment contains any of the specific strings
35+
- name: Block user from the org if their comment contained any of the banned strings
3636
if: steps.check_comment.outputs.result == 'true'
3737
uses: actions/github-script@v7
3838
with:
3939
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
40+
const username = context.payload.comment.user.login
41+
await github.rest.orgs.blockUser({
42+
org: context.repo.owner,
43+
username: username
4544
});

0 commit comments

Comments
 (0)