Files
neovim/.github/workflows/labeler_issue.yml
Justin M. Keyes 61abef3564 ci: combine PR-labeler jobs #40842
Problem:
We have 5 "labeler" jobs, this is kind of nuts, it bloats the CI report,
and also introduces race conditions...

Solution:
Merge 3 jobs into 1 `label` job with multiple sequential steps.
- Eliminates the `needs` chain
- Drops unused `contents:write` permission.
- GITHUB_TOKEN is scoped to the single `gh` step.
  - Note: is the automatic job token (`contents:read` + `pull-requests:write`,
    not a PAT), so worst case is PR/label mischief.

The `ai-assisted` and `request-reviewer` jobs stay separate, bc they are
triggered on different events (not only "opened").
2026-07-19 12:52:49 -04:00

49 lines
1.2 KiB
YAML

name: "label-issue"
on:
issues:
types: [opened]
permissions: {}
jobs:
labeler:
permissions:
issues: write
runs-on: ubuntu-latest
steps:
- name: check issue title
uses: actions/github-script@v9
with:
script: |
const title = context.payload.issue.title;
const titleSplit = title.split(/\b/).map(e => e.toLowerCase());
const keywords = [
'api',
'image',
'lsp',
'treesitter',
'ui',
'ui2'
];
var labels = new Set();
for (const keyword of keywords) {
if (titleSplit.includes(keyword)) {
labels.add(keyword)
}
}
// Special cases.
if (titleSplit.includes('vim.pack')) {
labels.add('packages')
}
if (labels.size !== 0) {
github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: Array.from(labels)
})
}