-
Notifications
You must be signed in to change notification settings - Fork 0
30 lines (30 loc) · 1.08 KB
/
Copy pathauto-label.yml
File metadata and controls
30 lines (30 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
name: Auto Label
on:
pull_request:
types: [opened, reopened, synchronized]
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) {
if (file.filename.endsWith('.js') || file.filename.endsWith('.ts')) labels.add('logic');
if (file.filename.includes('test')) labels.add('testing');
if (file.filename.includes('.github/workflows')) labels.add('ci-cd');
}
if (labels.size > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: Array.from(labels),
});
}