diff --git a/.github/workflows/label-community-pr.yml b/.github/workflows/label-community-pr.yml new file mode 100644 index 000000000000..52ec9e3204d5 --- /dev/null +++ b/.github/workflows/label-community-pr.yml @@ -0,0 +1,28 @@ +name: Label community PRs + +on: + pull_request: + types: + - opened + +jobs: + check_author: + runs-on: ubuntu-latest + + steps: + - name: Check PR Author Membership + id: check_membership + uses: octokit/request-action@v2.x + with: + route: GET /orgs/Kong/memberships/${{ github.event.pull_request.user.login }} + + - name: Add Label if Author is not a member + if: steps.check_membership.outputs.data.state != 'active' + run: | + echo "Author is not a member. Adding label..." + TOKEN=${{ secrets.GITHUB_TOKEN } + PR_NUMBER=${{ github.event.pull_request.number }} + LABEL="author/community" + API_URL="https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/labels" + + curl -X POST -H "Authorization: token $TOKEN" -d '["'"$LABEL"'"]' $API_URL