From 986a515a62d2df52609a79e739b8a77864a2588a Mon Sep 17 00:00:00 2001 From: Justin Ibarra Date: Fri, 13 Aug 2021 22:36:59 -0800 Subject: [PATCH] Add label workflow for community issues and pulls (#1406) * Add label workflow for community issues and pulls * run on label changes (cherry picked from commit 006cb0e7024a4da60a459f97bb4a1a15f49793f8) --- .github/workflows/community.yml | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/community.yml diff --git a/.github/workflows/community.yml b/.github/workflows/community.yml new file mode 100644 index 000000000..59b1818ff --- /dev/null +++ b/.github/workflows/community.yml @@ -0,0 +1,38 @@ +name: Community + +on: + pull_request_target: + types: + - opened + issues: + types: + - opened + label: + types: ["*"] + +jobs: + community-label: + runs-on: ubuntu-latest + steps: + - name: Determine membership + uses: actions/github-script@v4 + id: membership + with: + github-token: ${{ secrets.READ_ORG_TOKEN }} + script: | + return github.orgs.getMembershipForAuthenticatedUser({ + org: "elastic", + username: context.payload.sender.login + }) + - name: Add community label for users not in Elastic org + uses: actions/github-script@v4 + if: | + "${{ steps.membership.outputs.result.state }}" != "active" + with: + script: | + github.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['community'] + })