|
9 | 9 | steps: |
10 | 10 | - uses: actions/checkout@v4 |
11 | 11 | - name: Extract Netlify URL |
12 | | - id: netlify_url |
13 | 12 | run: | |
14 | 13 | repo_name=$(echo ${{ github.repository }} | cut -d'/' -f2) |
15 | | - echo "::set-output name=url::https://deploy-preview-${{ github.event.issue.number }}--${repo_name}.netlify.app" |
| 14 | + echo "NETLIFY_URL=https://deploy-preview-${{ github.event.issue.number }}--${repo_name}.netlify.app" >> $GITHUB_ENV |
16 | 15 | - name: Check PR author's privileges |
17 | | - run: | |
18 | | - response=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/${{ github.repository }}/collaborators/${{ github.event.pull_request.user.login }}/permission") |
19 | | - permission=$(echo $response | jq -r '.permission') |
20 | | - if [[ "$permission" != "admin" && "$permission" != "write" ]]; then |
21 | | - echo "::error::The PR author does not have 'admin' or 'write' privileges." |
22 | | - exit 1 |
23 | | - else |
24 | | - echo "The PR author has 'admin' or 'write' privileges." |
25 | | - fi |
| 16 | + uses: actions/github-script@v4 |
| 17 | + with: |
| 18 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 19 | + script: | |
| 20 | + const pr_details = await github.pulls.get({ |
| 21 | + ...context.repo, |
| 22 | + pull_number: context.issue.number, |
| 23 | + }); |
| 24 | + const response = await github.repos.getCollaboratorPermissionLevel({ |
| 25 | + ...context.repo, |
| 26 | + username: pr_details.data.user.login, |
| 27 | + }); |
| 28 | + const permission = response.data.permission; |
| 29 | + if (permission !== 'admin' && permission !== 'write') { |
| 30 | + core.setFailed("The PR author does not have 'admin' or 'write' privileges."); |
| 31 | + } |
26 | 32 | - name: Trigger Browser Compatibility Tests |
27 | 33 | uses: actions/github-script@v4 |
28 | 34 | with: |
|
32 | 38 | owner: 'sendbird', |
33 | 39 | repo: 'qe-browser-compatibility', |
34 | 40 | event_type: 'bct-test-trigger', |
35 | | - client_payload: { |
| 41 | + client_payload: { |
36 | 42 | prNumber: ${{ github.event.issue.number }}, |
37 | 43 | repoName: '${{ github.repository }}', |
38 | | - uikit_url: '${{ steps.netlify_url.outputs.url }}' |
| 44 | + uikit_url: '${{ env.NETLIFY_URL }}' |
39 | 45 | } |
40 | 46 | }) |
0 commit comments