-
-
Notifications
You must be signed in to change notification settings - Fork 12.3k
40 lines (38 loc) · 1.24 KB
/
labeler.yml
File metadata and controls
40 lines (38 loc) · 1.24 KB
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
name: "Pull Request Labeler"
on:
pull_request_target:
types: [opened]
permissions: {}
jobs:
pr-labeler:
if: github.repository == 'numpy/numpy'
runs-on: ubuntu-latest
permissions:
pull-requests: write # to add labels
steps:
- name: Label the PR
continue-on-error: true
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const yaml = require('js-yaml');
const {data} = await github.rest.repos.getContent({
owner: context.repo.owner,
repo: context.repo.repo,
path: '.github/pr-prefix-labeler.yml',
});
const prefixToLabel = yaml.load(
Buffer.from(data.content, data.encoding).toString()
);
const title = context.payload.pull_request.title;
for (const [prefix, label] of Object.entries(prefixToLabel)) {
if (title.startsWith(prefix)) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: [label],
});
break;
}
}