aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/pr_check.yml
diff options
context:
space:
mode:
authorNikita Kozlovskiy <nikitka@gmail.com>2023-06-10 15:51:18 +0000
committernkozlovskiy <nmk@ydb.tech>2023-06-10 18:51:18 +0300
commit5937242d7c3791b37a6a52872f9560691035e9a0 (patch)
tree9c123ba9788c1deee5d3b635213171186f32e39b /.github/workflows/pr_check.yml
parent826c296285ccfa60ea2b311f2e67f8954e8074fe (diff)
downloadydb-5937242d7c3791b37a6a52872f9560691035e9a0.tar.gz
ci: pr check fix
ci: pr check fix Pull Request resolved: #250
Diffstat (limited to '.github/workflows/pr_check.yml')
-rw-r--r--.github/workflows/pr_check.yml34
1 files changed, 23 insertions, 11 deletions
diff --git a/.github/workflows/pr_check.yml b/.github/workflows/pr_check.yml
index f9380be0fe..82dd18e3ff 100644
--- a/.github/workflows/pr_check.yml
+++ b/.github/workflows/pr_check.yml
@@ -26,22 +26,33 @@ jobs:
with:
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
script: |
- // This is used primarily in forks. Repository owner
- // should be allowed to run anything.
+ // This is used primarily in forks. Repository owner
+ // should be allowed to run anything.
const userLogin = context.payload.pull_request.user.login;
+
+ // How to interpret membership status code:
+ // https://docs.github.com/en/rest/orgs/members?apiVersion=2022-11-28#check-organization-membership-for-a-user
+ const isOrgMember = async function () {
+ try {
+ const response = await github.rest.orgs.checkMembershipForUser({
+ org: context.payload.organization.login,
+ username: userLogin,
+ });
+ return response.status == 204;
+ } catch (error) {
+ if (error.status && error.status == 404) {
+ return false;
+ }
+ throw error;
+ }
+ }
+
if (context.payload.repository.owner.login == userLogin) {
return true;
}
- const response = await github.rest.orgs.checkMembershipForUser({
- org: context.payload.organization.login,
- username: userLogin,
- });
-
- // How to interpret membership status code:
- // https://docs.github.com/en/rest/orgs/members?apiVersion=2022-11-28#check-organization-membership-for-a-user
- if (response.status == '204') {
- return true;
+ if (await isOrgMember()) {
+ return true;
}
const labels = context.payload.pull_request.labels;
@@ -54,6 +65,7 @@ jobs:
github.event.action == 'opened'
uses: actions/github-script@v6
with:
+ github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,