Skip to content

Commit c403a91

Browse files
authored
ci: update (#1063)
- update workflow
1 parent fcacbbb commit c403a91

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

.github/workflows/bct.yml

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,26 @@ jobs:
99
steps:
1010
- uses: actions/checkout@v4
1111
- name: Extract Netlify URL
12-
id: netlify_url
1312
run: |
1413
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
1615
- 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+
}
2632
- name: Trigger Browser Compatibility Tests
2733
uses: actions/github-script@v4
2834
with:
@@ -32,9 +38,9 @@ jobs:
3238
owner: 'sendbird',
3339
repo: 'qe-browser-compatibility',
3440
event_type: 'bct-test-trigger',
35-
client_payload: {
41+
client_payload: {
3642
prNumber: ${{ github.event.issue.number }},
3743
repoName: '${{ github.repository }}',
38-
uikit_url: '${{ steps.netlify_url.outputs.url }}'
44+
uikit_url: '${{ env.NETLIFY_URL }}'
3945
}
4046
})

0 commit comments

Comments
 (0)