Skip to content

Bump ajv from 8.17.1 to 8.18.0 #38

Bump ajv from 8.17.1 to 8.18.0

Bump ajv from 8.17.1 to 8.18.0 #38

Workflow file for this run

name: Auto Label
on:
pull_request:
types: [opened, reopened, synchronized]
permissions:
contents: read
pull-requests: write
jobs:
label:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
script: |
const { data: files } = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number
});
const labels = new Set();
for (const file of files) {
const path = file.filename;
if (path.includes('docs/') || path.endsWith('.md')) labels.add('documentation');
if (path.includes('test/') || path.includes('.test.') || path.includes('.spec.')) labels.add('tests');
if (path.includes('.github/workflows/')) labels.add('ci/cd');
if (path.endsWith('.js') || path.endsWith('.ts') || path.endsWith('.jsx') || path.endsWith('.tsx')) labels.add('javascript');
if (path.endsWith('.py')) labels.add('python');
if (path.endsWith('.css') || path.endsWith('.scss') || path.endsWith('.sass')) labels.add('styling');
}
// Fetch existing labels in the repository to avoid "Label does not exist" errors
const { data: repoLabels } = await github.rest.issues.listLabelsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 100,
});
const existingLabelNames = new Set(repoLabels.map(label => label.name));
const labelsToAdd = Array.from(labels).filter(label => existingLabelNames.has(label));
if (labelsToAdd.length > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: labelsToAdd,
});
}