From 5fecdfa1c89d5609d7bcdb908dadf204f126f500 Mon Sep 17 00:00:00 2001 From: rambohe-ch Date: Fri, 10 Nov 2023 11:03:00 +0800 Subject: [PATCH] fix collaborator permission check error --- .github/workflows/rerun-failed-workflows.yaml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/rerun-failed-workflows.yaml b/.github/workflows/rerun-failed-workflows.yaml index 43fa57af0cc..82ece6fd72f 100644 --- a/.github/workflows/rerun-failed-workflows.yaml +++ b/.github/workflows/rerun-failed-workflows.yaml @@ -24,18 +24,19 @@ jobs: }); if (regex.test(comment.data.body)) { - try { - await github.rest.repos.checkUserAccessLevel({ + const collaborator = await github.rest.repos.getCollaboratorPermissionLevel({ owner: issue.owner, repo: issue.repo, username: username, - permission: 'read' }); - return true; - } catch (error) { - console.log(`User ${username} does not have access to rerun failed workflows`); - return false; - } + + if (collaborator.permission != 'write' && collaborator.permission != 'admin')} { + console.log(`User ${username} with permission ${collaborator.permission} does not have access to rerun failed workflows`); + return false; + } else { + console.log(`User ${username} with permission ${collaborator.permission} has access to rerun failed workflows`); + return true; + } } else { return false; }