-
Notifications
You must be signed in to change notification settings - Fork 511
52 lines (46 loc) · 1.54 KB
/
community.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
name: Community
on:
pull_request_target:
types:
- opened
issues:
types:
- opened
jobs:
label:
runs-on: ubuntu-latest
steps:
- name: Check if member of elastic org
uses: actions/github-script@v6
id: membership
with:
github-token: ${{ secrets.READ_ORG_TOKEN }}
result-encoding: string
script: |
try {
const result = await github.rest.orgs.getMembershipForUser({
org: "elastic",
username: '${{ github.actor }}'
})
console.log(result?.data?.state)
if (result?.data?.state == "active"){
console.log("%s: detected as an active member of elastic org", '${{ github.actor }}')
return "member";
} else {
console.log("%s: not detected as active member of elastic org", '${{ github.actor }}')
return "notMember";
}
} catch (error) {
return "notMember";
}
- name: Add label for community members
uses: actions/github-script@v6
if: ${{ steps.membership.outputs.result == 'notMember' }}
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['community']
})