Skip to content

deps: breaking: update @typescript-eslint dependencies #1499

deps: breaking: update @typescript-eslint dependencies

deps: breaking: update @typescript-eslint dependencies #1499

name: Pull request labels autocreation
on:
pull_request:
types: [opened, synchronize]
jobs:
create-labels-from-files:
name: 'create labels from files'
runs-on: ubuntu-latest
steps:
- name: Create labels from files
id: version
uses: actions/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: files } = await github.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
per_page: 100,
});
const labelSet = files.reduce(
(labels, file) => {
const filePath = file.filename;
const maybeMatch = /packages\/([\w.\-_]*)\/.*/.exec(filePath);
if (!maybeMatch) {
return labels;
}
const [, packageName] = maybeMatch;
const label = `packages/${packageName}`;
labels.add(label);
return labels;
},
new Set([]),
);
if (labelSet.size === 0) {
console.log(`::debug ::No labels extracted from files`);
return;
}
const labels = Array.from(labelSet);
await github.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels,
});