-
Notifications
You must be signed in to change notification settings - Fork 3
74 lines (61 loc) · 2.11 KB
/
pr-auto-label.yml
File metadata and controls
74 lines (61 loc) · 2.11 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Auto Label PR
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
label:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect changed apps
id: detect
run: |
# Get changed files between base and head
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
FILES=$(git diff --name-only $BASE_SHA $HEAD_SHA)
echo "Changed files:"
echo "$FILES"
# Check for web changes
if echo "$FILES" | grep -q "^apps/web/"; then
echo "web=true" >> $GITHUB_OUTPUT
echo "✓ Detected changes in apps/web"
else
echo "web=false" >> $GITHUB_OUTPUT
fi
# Check for admin changes
if echo "$FILES" | grep -q "^apps/admin/"; then
echo "admin=true" >> $GITHUB_OUTPUT
echo "✓ Detected changes in apps/admin"
else
echo "admin=false" >> $GITHUB_OUTPUT
fi
- name: Add labels
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const labels = [];
if ('${{ steps.detect.outputs.web }}' === 'true') {
labels.push('web');
}
if ('${{ steps.detect.outputs.admin }}' === 'true') {
labels.push('admin');
}
if (labels.length > 0) {
console.log(`Adding labels: ${labels.join(', ')}`);
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: labels
});
} else {
console.log('No app-specific changes detected');
}