diff options
author | Nikita Kozlovskiy <nikitka@gmail.com> | 2023-06-10 15:51:18 +0000 |
---|---|---|
committer | nkozlovskiy <nmk@ydb.tech> | 2023-06-10 18:51:18 +0300 |
commit | 5937242d7c3791b37a6a52872f9560691035e9a0 (patch) | |
tree | 9c123ba9788c1deee5d3b635213171186f32e39b | |
parent | 826c296285ccfa60ea2b311f2e67f8954e8074fe (diff) | |
download | ydb-5937242d7c3791b37a6a52872f9560691035e9a0.tar.gz |
ci: pr check fix
ci: pr check fix
Pull Request resolved: #250
-rw-r--r-- | .github/workflows/pr_check.yml | 34 |
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, |