-
Notifications
You must be signed in to change notification settings - Fork 17
46 lines (42 loc) · 1.47 KB
/
need-triage-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
name: Auto Label Issues
on:
issues:
types: [opened]
jobs:
triage:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check if opener is CODEOWNER
id: check-codeowner
run: |
# Get the CODEOWNERS file content
if [ -f .github/CODEOWNERS ]; then
# Extract GitHub usernames from CODEOWNERS file
CODEOWNERS=$(grep -v '^#' .github/CODEOWNERS | grep -o '@[a-zA-Z0-9-]*' | sed 's/@//')
# Check if issue opener is in CODEOWNERS
if echo "$CODEOWNERS" | grep -q "^${{ github.event.issue.user.login }}$"; then
echo "is_codeowner=true" >> $GITHUB_OUTPUT
else
echo "is_codeowner=false" >> $GITHUB_OUTPUT
fi
else
echo "is_codeowner=false" >> $GITHUB_OUTPUT
fi
- name: Add need-triage label
if: steps.check-codeowner.outputs.is_codeowner == 'false'
uses: actions/github-script@v7
with:
script: |
try {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: ['need-triage']
});
console.log('Successfully added `need-triage` label');
} catch (error) {
console.log('Error adding label:', error);
}