File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -9,12 +9,33 @@ permissions:
99 pull-requests : write
1010
1111jobs :
12- run-style-bot :
12+ check-permissions :
1313 if : >
1414 contains(github.event.comment.body, '@bot /style') &&
1515 github.event.issue.pull_request != null
1616 runs-on : ubuntu-latest
17+ outputs :
18+ is_authorized : ${{ steps.check_user_permission.outputs.has_permission }}
19+ steps :
20+ - name : Check user permission
21+ id : check_user_permission
22+ uses : actions/github-script@v6
23+ with :
24+ script : |
25+ const comment_user = context.payload.comment.user.login;
26+ const { data: permission } = await github.rest.repos.getCollaboratorPermissionLevel({
27+ owner: context.repo.owner,
28+ repo: context.repo.repo,
29+ username: comment_user
30+ });
31+ const authorized = permission.permission === 'admin';
32+ console.log(`User ${comment_user} has permission level: ${permission.permission}, authorized: ${authorized} (only admins allowed)`);
33+ core.setOutput('has_permission', authorized);
1734
35+ run-style-bot :
36+ needs : check-permissions
37+ if : needs.check-permissions.outputs.is_authorized == 'true'
38+ runs-on : ubuntu-latest
1839 steps :
1940 - name : Extract PR details
2041 id : pr_info
You can’t perform that action at this time.
0 commit comments