actions: label GH issues automagically
Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
name: Sync Issue Labels
|
||||
on:
|
||||
issues:
|
||||
types: [opened]
|
||||
jobs:
|
||||
label-issue:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: View context attributes
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
const keywords = {
|
||||
'techdocs*|tech-docs|tech docs': 'docs-like-code',
|
||||
'search*': 'search',
|
||||
'catalog*': 'catalog',
|
||||
'scaffolder*': 'scaffolder',
|
||||
};
|
||||
|
||||
const labels = Object.entries(keywords)
|
||||
.map(([regexp, label]) => {
|
||||
if (new RegExp(regexp, 'gi').test(context.payload.issue.title)) {
|
||||
return label;
|
||||
}
|
||||
})
|
||||
.filter(Boolean);
|
||||
|
||||
if(!labels.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
github.rest.issues.addLabels({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
labels
|
||||
});
|
||||
Reference in New Issue
Block a user