-
Notifications
You must be signed in to change notification settings - Fork 38
49 lines (39 loc) · 1.65 KB
/
add_label.yml
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: "Add labels"
on:
pull_request:
permissions:
pull-requests: write
jobs:
apply-label:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- uses: actions/github-script@v7
with:
script: |
const { execSync } = require('child_process')
const { commits } = context.payload.pull_request
const rawFiles = execSync(`git diff --name-only HEAD HEAD~${commits}`).toString()
const files = rawFiles.split('\n').filter(Boolean)
// verify packages
const packagesFiles = files.filter(file => file.startsWith('packages/') && !file.includes('mix_lint_test'))
const packages = packagesFiles.map(file => file.split('/')[1])
const labels = Array.from(new Set(packages))
// verify documentation
const packagesFiles = files.filter(file => file.startsWith('website/'))
labels.push('documentation')
// verify documentation
const packagesFiles = files.filter(file => file.startsWith('examples/'))
labels.push('examples')
// verify documentation
const packagesFiles = files.filter(file => !file.startsWith('website/') && !file.startsWith('packages/') && file.startsWith('!file.startsWith('examples/')'))
labels.push('repo')
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labels
})