Skip to content

nc-review: severity calibration, issue resolution, and warranted checks #134

nc-review: severity calibration, issue resolution, and warranted checks

nc-review: severity calibration, issue resolution, and warranted checks #134

Workflow file for this run

name: PR path labels
on:
pull_request_target:
types: [opened, synchronize, reopened]
branches: [main]
permissions:
contents: read
issues: write
pull-requests: write
jobs:
label:
runs-on: ubuntu-latest
# Skip the automated "Version Packages" PR.
if: github.head_ref != 'changeset-release/main'
steps:
- name: Color area labels
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const colors = {
'area:tools': ['1d76db', 'Tool implementations and tool-calling'],
'area:tui': ['fbca04', 'Terminal UI'],
'area:ci': ['e99695', 'GitHub Actions and CI'],
'area:docs': ['0e8a16', 'Documentation'],
'area:vscode': ['5319e7', 'VS Code extension and host integration'],
};
const {owner, repo} = context.repo;
const {data} = await github.rest.repos.getContent({
owner,
repo,
path: '.github/labeler.yml',
ref: context.payload.pull_request.base.sha,
});
if (data.type !== 'file' || typeof data.content !== 'string') {
throw new Error('labeler.yml is not a file');
}
const yaml = Buffer.from(data.content, 'base64').toString('utf8');
const names = [...yaml.matchAll(/^(\S+):\s*$/gm)].map(m => m[1]);
if (names.length === 0) {
throw new Error('labeler.yml had no top-level label keys');
}
for (const name of names) {
const meta = colors[name];
if (!meta) {
throw new Error(
`labeler.yml has ${name} but no colour map entry`,
);
}
try {
await github.rest.issues.getLabel({owner, repo, name});
} catch (error) {
if (error.status !== 404) throw error;
const [color, description] = meta;
await github.rest.issues.createLabel({
owner,
repo,
name,
color,
description,
});
}
}
- name: Label by path
uses: actions/labeler@bf12e9b00b37c5c0ca2b87b79b2daf7891dbda13 # v7.0.0
with:
sync-labels: false