diff --git a/.github/workflows/sync_issue-labels.yml b/.github/workflows/sync_issue-labels.yml new file mode 100644 index 0000000000..6a1c33348a --- /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 + });