-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (47 loc) · 1.42 KB
/
label-sync.yml
File metadata and controls
59 lines (47 loc) · 1.42 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
name: Label PRs
on:
pull_request:
types: [opened, synchronize]
permissions:
contents: read
pull-requests: write
jobs:
label:
name: Auto-label by path
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get changed files
id: changed
run: |
FILES=$(gh pr diff ${{ github.event.pull_request.number }} --name-only)
echo "files<<EOF" >> "$GITHUB_OUTPUT"
echo "$FILES" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Apply labels
run: |
LABELS=""
if echo "$FILES" | grep -q "^skills/"; then
LABELS="$LABELS,skills"
fi
if echo "$FILES" | grep -q "^rules/"; then
LABELS="$LABELS,rules"
fi
if echo "$FILES" | grep -q "^mcp-server/"; then
LABELS="$LABELS,mcp-server"
fi
if echo "$FILES" | grep -q "^docs/"; then
LABELS="$LABELS,documentation"
fi
if echo "$FILES" | grep -q "^\.github/"; then
LABELS="$LABELS,ci"
fi
LABELS="${LABELS#,}"
if [ -n "$LABELS" ]; then
gh pr edit ${{ github.event.pull_request.number }} --add-label "$LABELS"
fi
env:
FILES: ${{ steps.changed.outputs.files }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}