From 678390db83ba78de3dd77eed7dee649a8200aced Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Thu, 17 Mar 2022 13:40:02 +0100 Subject: [PATCH 1/3] actions: label GH issues automagically Signed-off-by: Johan Haals --- .github/workflows/sync_issue-labels.yml | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/sync_issue-labels.yml diff --git a/.github/workflows/sync_issue-labels.yml b/.github/workflows/sync_issue-labels.yml new file mode 100644 index 0000000000..079b5e1c88 --- /dev/null +++ b/.github/workflows/sync_issue-labels.yml @@ -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 + }); From 316a3a682adb11febfd7b4dbbb8e3e2874a1b402 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Thu, 17 Mar 2022 13:58:14 +0100 Subject: [PATCH 2/3] drop asterisk Signed-off-by: Johan Haals --- .github/workflows/sync_issue-labels.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sync_issue-labels.yml b/.github/workflows/sync_issue-labels.yml index 079b5e1c88..b6b4008091 100644 --- a/.github/workflows/sync_issue-labels.yml +++ b/.github/workflows/sync_issue-labels.yml @@ -11,10 +11,10 @@ jobs: with: script: | const keywords = { - 'techdocs*|tech-docs|tech docs': 'docs-like-code', - 'search*': 'search', - 'catalog*': 'catalog', - 'scaffolder*': 'scaffolder', + 'techdocs|tech-docs|tech docs': 'docs-like-code', + 'search': 'search', + 'catalog': 'catalog', + 'scaffolder': 'scaffolder', }; const labels = Object.entries(keywords) From 0d217cbc021eb753ca3164503e8328755e293a82 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Thu, 17 Mar 2022 13:58:51 +0100 Subject: [PATCH 3/3] format Signed-off-by: Johan Haals --- .github/workflows/sync_issue-labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync_issue-labels.yml b/.github/workflows/sync_issue-labels.yml index b6b4008091..6a1c33348a 100644 --- a/.github/workflows/sync_issue-labels.yml +++ b/.github/workflows/sync_issue-labels.yml @@ -28,7 +28,7 @@ jobs: if(!labels.length) { return; } - + github.rest.issues.addLabels({ issue_number: context.issue.number, owner: context.repo.owner,