actions: label GH issues automagically

Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
Johan Haals
2022-03-17 13:40:02 +01:00
parent 83072184fd
commit 678390db83
+37
View File
@@ -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
});