|
1 |
| -name: Scrape and Update Repo |
| 1 | +name: MCP Server Info Bot |
2 | 2 |
|
3 | 3 | permissions:
|
4 | 4 | contents: write
|
|
12 | 12 | jobs:
|
13 | 13 | scrape-and-update:
|
14 | 14 | runs-on: ubuntu-latest
|
15 |
| - if: github.event.label.name == 'new-server' # Trigger only on 'new-server' label |
| 15 | + if: github.event.label.name == 'mcp-server-info-bot' # Trigger only on 'mcp-server-info-bot' label |
16 | 16 | steps:
|
17 |
| - - name: Check if user is authorized |
18 |
| - env: |
19 |
| - SENDER: ${{ github.event.sender.login }} |
| 17 | + - name: Check if user is a maintainer |
| 18 | + uses: actions/github-script@v6 |
| 19 | + id: check-maintainer |
| 20 | + with: |
| 21 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 22 | + script: | |
| 23 | + const sender = context.payload.sender.login; |
| 24 | + const { owner, repo } = context.repo; |
| 25 | + |
| 26 | + try { |
| 27 | + // Check if user has write access (maintainer or higher) |
| 28 | + const { data: permission } = await github.rest.repos.getCollaboratorPermissionLevel({ |
| 29 | + owner: owner, |
| 30 | + repo: repo, |
| 31 | + username: sender |
| 32 | + }); |
| 33 | + |
| 34 | + const hasWriteAccess = ['admin', 'maintain', 'write'].includes(permission.permission); |
| 35 | + |
| 36 | + if (hasWriteAccess) { |
| 37 | + console.log(`✅ User ${sender} is a maintainer with ${permission.permission} permissions`); |
| 38 | + return true; |
| 39 | + } else { |
| 40 | + console.log(`❌ User ${sender} does not have sufficient permissions (${permission.permission})`); |
| 41 | + return false; |
| 42 | + } |
| 43 | + } catch (error) { |
| 44 | + console.log(`Error checking permissions: ${error.message}`); |
| 45 | + return false; |
| 46 | + } |
| 47 | + |
| 48 | + - name: Fail if not maintainer |
| 49 | + if: steps.check-maintainer.outputs.result != 'true' |
20 | 50 | run: |
|
21 |
| - # Custom list of authorized users (GitHub usernames) |
22 |
| - AUTHORIZED_USERS="jeremy-dai-txyz JoJoJoJoJoJoJo niechen" |
23 |
| - if echo "$AUTHORIZED_USERS" | grep -q -w "$SENDER"; then |
24 |
| - echo "User $SENDER is authorized" |
25 |
| - else |
26 |
| - echo "User $SENDER is not authorized" |
27 |
| - exit 1 |
28 |
| - fi |
| 51 | + echo "User ${{ github.event.sender.login }} does not have maintainer permissions" |
| 52 | + exit 1 |
29 | 53 |
|
30 | 54 | - name: Checkout repository
|
31 | 55 | uses: actions/checkout@v4
|
|
0 commit comments