|
7 | 7 | runs-on: ubuntu-latest |
8 | 8 | if: github.event.issue.pull_request && contains(github.event.comment.body, 'Deploy Preview for') && contains(github.event.comment.body, 'ready!') |
9 | 9 | steps: |
10 | | - - uses: actions/checkout@v3 |
11 | | - - name: Extract repository name |
12 | | - id: repo_name |
13 | | - run: echo "::set-output name=repo::$(echo ${{ github.repository }} | cut -d'/' -f2)" |
14 | | - - run: echo "https://deploy-preview-${{ github.event.issue.number }}--${{ steps.repo_name.outputs.repo }}.netlify.app" |
15 | | - - name: Dump GitHub context |
16 | | - env: |
17 | | - GITHUB_CONTEXT: ${{ toJson(github) }} |
18 | | - run: echo "$GITHUB_CONTEXT" |
19 | | - - name: Dump job context |
20 | | - env: |
21 | | - JOB_CONTEXT: ${{ toJson(job) }} |
22 | | - run: echo "$JOB_CONTEXT" |
| 10 | + - uses: actions/checkout@v4 |
| 11 | + - name: Extract Netlify URL |
| 12 | + id: netlify_url |
| 13 | + run: | |
| 14 | + 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" |
| 16 | + - 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 |
| 26 | + - name: Trigger Browser Compatibility Tests |
| 27 | + uses: actions/github-script@v4 |
| 28 | + with: |
| 29 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 30 | + script: | |
| 31 | + github.repos.createDispatchEvent({ |
| 32 | + owner: 'sendbird', |
| 33 | + repo: 'qe-browser-compatibility', |
| 34 | + event_type: 'bct-test-trigger', |
| 35 | + client_payload: { |
| 36 | + prNumber: ${{ github.event.issue.number }}, |
| 37 | + repoName: '${{ github.repository }}', |
| 38 | + uikit_url: '${{ steps.netlify_url.outputs.url }}' |
| 39 | + } |
| 40 | + }) |
0 commit comments