Skip to content

Commit

Permalink
feat: add automatic PR labeler in github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
TaiYou-TW committed Feb 29, 2024
1 parent 01554ce commit d418b85
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Automatic PR Labeler
on:
pull_request:
types: [opened, reopened, edited]

jobs:
labeler:
runs-on: ubuntu-latest
steps:
- name: Label PR
uses: actions/github-script@v5
with:
script: |
const { owner, repo, number: issue_number } = context.issue;
const pr = await github.rest.pulls.get({ owner, repo, pull_number: issue_number });
const title = pr.data.title;
const labRegex = /\[LAB(\d+)\]/i;
const match = title.match(labRegex);
if (match) {
const labelToAdd = 'lab' + match[1];
await github.rest.issues.addLabels({ owner, repo, issue_number, labels: [labelToAdd] });
}

0 comments on commit d418b85

Please sign in to comment.