Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/build-on-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,29 @@ jobs:
if: github.event.issue.pull_request != null && contains(github.event.comment.body, '/build')
runs-on: macos-15
steps:
- name: Check user permissions
run: |
COMMENTER="${{ github.event.comment.user.login }}"
RESPONSE=$(curl -s -w "\n%{http_code}" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/collaborators/$COMMENTER/permission")

HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
BODY=$(echo "$RESPONSE" | sed '$d')

if [[ "$HTTP_CODE" != "200" ]]; then
echo "❌ User $COMMENTER is not a collaborator"
exit 1
fi

PERMISSION=$(echo "$BODY" | jq -r '.permission')

if [[ "$PERMISSION" != "admin" && "$PERMISSION" != "write" ]]; then
echo "❌ User $COMMENTER has '$PERMISSION' permission - requires 'write' or 'admin' to trigger builds"
exit 1
fi

echo "✅ User $COMMENTER has '$PERMISSION' permission - authorized to trigger builds"

- name: React to build start
run: |
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
Expand Down
Loading