Skip to content

Commit

Permalink
check permission
Browse files Browse the repository at this point in the history
  • Loading branch information
docimin committed Dec 22, 2024
1 parent 40ea156 commit e8e4fca
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/comment-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ jobs:
node: [22.x]

steps:
- name: Check comment author permissions
id: check-permissions
run: |
PERMISSION=$(gh api \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/collaborators/${{ github.event.comment.user.login }}/permission \
--jq '.permission')
echo "User permission: $PERMISSION"
if [[ "$PERMISSION" != "admin" && "$PERMISSION" != "maintain" && "$PERMISSION" != "write" ]]; then
echo "User does not have sufficient permissions to trigger the build."
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 💬 Post initial status comment
id: comment
run: |
Expand Down

0 comments on commit e8e4fca

Please sign in to comment.