Skip to content

Commit d418b85

Browse files
committed
feat: add automatic PR labeler in github workflow
1 parent 01554ce commit d418b85

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

.github/workflows/label.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Automatic PR Labeler
2+
on:
3+
pull_request:
4+
types: [opened, reopened, edited]
5+
6+
jobs:
7+
labeler:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Label PR
11+
uses: actions/github-script@v5
12+
with:
13+
script: |
14+
const { owner, repo, number: issue_number } = context.issue;
15+
const pr = await github.rest.pulls.get({ owner, repo, pull_number: issue_number });
16+
const title = pr.data.title;
17+
const labRegex = /\[LAB(\d+)\]/i;
18+
19+
const match = title.match(labRegex);
20+
if (match) {
21+
const labelToAdd = 'lab' + match[1];
22+
await github.rest.issues.addLabels({ owner, repo, issue_number, labels: [labelToAdd] });
23+
}

0 commit comments

Comments
 (0)