From c85381114304757e33af2fce43c6a1ce822ea635 Mon Sep 17 00:00:00 2001 From: Maksym H Date: Wed, 21 Aug 2024 12:51:31 +0100 Subject: [PATCH] Update cmd.yml --- .github/workflows/cmd.yml | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cmd.yml b/.github/workflows/cmd.yml index d5e1176fb4266..2c01249d38ea9 100644 --- a/.github/workflows/cmd.yml +++ b/.github/workflows/cmd.yml @@ -19,17 +19,36 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Generate token + id: generate_token + uses: tibdex/github-app-token@v2.1.0 + with: + app_id: ${{ secrets.CMD_BOT_APP_ID }} + private_key: ${{ secrets.CMD_BOT_APP_KEY }} + - name: Check if user is a member of the organization id: is-member uses: actions/github-script@v7 with: - github-token: ${{ secrets.GITHUB_TOKEN }} + github-token: ${{ steps.generate_token.outputs.token }} script: | - const membership = await github.rest.orgs.checkMembershipForUser({ - org: context.repo.owner, - username: context.actor - }) - return membership.data.state === 'active' + try { + const org = 'paritytech'; + const username = context.actor; + const membership = await github.rest.orgs.checkMembershipForUser({ + org: org, + username: username + }); + console.log(membership) + + } catch (error) { + console.log(error) + return { 'is-member': false } + } + + return { + 'is-member': membership.status === 204 + } reject-non-members: needs: is-org-member