|
18 | 18 | runs-on: ubuntu-latest
|
19 | 19 |
|
20 | 20 | steps:
|
| 21 | + - if: github.event.issue.pull_request |
| 22 | + uses: actions/github-script@v7 |
| 23 | + with: |
| 24 | + script: | |
| 25 | + const user = context.payload.sender.login |
| 26 | + console.log(`Validate user: ${user}`) |
| 27 | +
|
| 28 | + let hasTriagePermission = false |
| 29 | + try { |
| 30 | + const { data } = await github.rest.repos.getCollaboratorPermissionLevel({ |
| 31 | + owner: context.repo.owner, |
| 32 | + repo: context.repo.repo, |
| 33 | + username: user, |
| 34 | + }); |
| 35 | + hasTriagePermission = data.user.permissions.triage |
| 36 | + } catch (e) { |
| 37 | + console.warn(e) |
| 38 | + } |
| 39 | +
|
| 40 | + if (hasTriagePermission) { |
| 41 | + console.log('Allowed') |
| 42 | + await github.rest.reactions.createForIssueComment({ |
| 43 | + owner: context.repo.owner, |
| 44 | + repo: context.repo.repo, |
| 45 | + comment_id: context.payload.comment.id, |
| 46 | + content: '+1', |
| 47 | + }) |
| 48 | + } else { |
| 49 | + console.log('Not allowed') |
| 50 | + await github.rest.reactions.createForIssueComment({ |
| 51 | + owner: context.repo.owner, |
| 52 | + repo: context.repo.repo, |
| 53 | + comment_id: context.payload.comment.id, |
| 54 | + content: '-1', |
| 55 | + }) |
| 56 | + throw new Error('not allowed') |
| 57 | + } |
| 58 | +
|
21 | 59 | - name: Checkout code
|
22 |
| - uses: actions/checkout@v3 |
| 60 | + uses: actions/checkout@v4 |
23 | 61 |
|
24 | 62 | - name: Install pnpm
|
25 | 63 |
|
|
0 commit comments