Skip to content

Commit

Permalink
[CI] Update Stylebot Permissions (huggingface#10931)
Browse files Browse the repository at this point in the history
update
  • Loading branch information
DN6 authored Mar 1, 2025
1 parent d230ecc commit 7007feb
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion .github/workflows/pr_style_bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,33 @@ permissions:
pull-requests: write

jobs:
run-style-bot:
check-permissions:
if: >
contains(github.event.comment.body, '@bot /style') &&
github.event.issue.pull_request != null
runs-on: ubuntu-latest
outputs:
is_authorized: ${{ steps.check_user_permission.outputs.has_permission }}
steps:
- name: Check user permission
id: check_user_permission
uses: actions/github-script@v6
with:
script: |
const comment_user = context.payload.comment.user.login;
const { data: permission } = await github.rest.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner,
repo: context.repo.repo,
username: comment_user
});
const authorized = permission.permission === 'admin';
console.log(`User ${comment_user} has permission level: ${permission.permission}, authorized: ${authorized} (only admins allowed)`);
core.setOutput('has_permission', authorized);
run-style-bot:
needs: check-permissions
if: needs.check-permissions.outputs.is_authorized == 'true'
runs-on: ubuntu-latest
steps:
- name: Extract PR details
id: pr_info
Expand Down

0 comments on commit 7007feb

Please sign in to comment.