Skip to content

Commit

Permalink
fix collaborator permission check error
Browse files Browse the repository at this point in the history
  • Loading branch information
rambohe-ch committed Nov 10, 2023
1 parent 866cf75 commit 5fecdfa
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/rerun-failed-workflows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 5fecdfa

Please sign in to comment.