Skip to content

Commit 677f90b

Browse files
authored
chore: label community PRs on open (#23157)
1 parent d697213 commit 677f90b

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

.github/workflows/contrib.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,44 @@ permissions:
2323
concurrency: pr-${{ github.ref }}
2424

2525
jobs:
26+
community-label:
27+
runs-on: ubuntu-latest
28+
permissions:
29+
pull-requests: write
30+
if: >-
31+
${{
32+
github.event_name == 'pull_request_target' &&
33+
github.event.action == 'opened' &&
34+
github.event.pull_request.author_association != 'MEMBER' &&
35+
github.event.pull_request.author_association != 'COLLABORATOR' &&
36+
github.event.pull_request.author_association != 'OWNER'
37+
}}
38+
steps:
39+
- name: Add community label
40+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
41+
with:
42+
script: |
43+
const params = {
44+
issue_number: context.issue.number,
45+
owner: context.repo.owner,
46+
repo: context.repo.repo,
47+
}
48+
49+
const labels = context.payload.pull_request.labels.map((label) => label.name)
50+
if (labels.includes("community")) {
51+
console.log('PR already has "community" label.')
52+
return
53+
}
54+
55+
console.log(
56+
'Adding "community" label for author association "%s".',
57+
context.payload.pull_request.author_association,
58+
)
59+
await github.rest.issues.addLabels({
60+
...params,
61+
labels: ["community"],
62+
})
63+
2664
cla:
2765
runs-on: ubuntu-latest
2866
permissions:

0 commit comments

Comments
 (0)