Skip to content

Commit b096e54

Browse files
Update triage.yml
1 parent a792d12 commit b096e54

File tree

1 file changed

+31
-54
lines changed

1 file changed

+31
-54
lines changed

.github/workflows/triage.yml

Lines changed: 31 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,25 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- name: Assign Labels to Issue
15-
if: github.event.issue != null
14+
- name: Assign Labels
1615
uses: actions/github-script@v6
1716
with:
1817
script: |
19-
const title = context.payload.issue.title.toLowerCase();
20-
const body = context.payload.issue.body ? context.payload.issue.body.toLowerCase() : '';
18+
let issue_number;
19+
let title = '';
20+
let body = '';
21+
if (context.payload.issue) {
22+
issue_number = context.payload.issue.number;
23+
title = context.payload.issue.title.toLowerCase();
24+
body = context.payload.issue.body ? context.payload.issue.body.toLowerCase() : '';
25+
} else if (context.payload.pull_request) {
26+
issue_number = context.payload.pull_request.number;
27+
title = context.payload.pull_request.title.toLowerCase();
28+
body = context.payload.pull_request.body ? context.payload.pull_request.body.toLowerCase() : '';
29+
} else {
30+
throw new Error('No issue or pull request found in context.');
31+
}
32+
2133
const labels = [];
2234
if (title.includes('bug') || body.includes('bug') || title.includes('error') || body.includes('error') || title.includes('problem') || body.includes('problem')) {
2335
labels.push('bug');
@@ -30,38 +42,27 @@ jobs:
3042
} else {
3143
labels.push('needs-triage');
3244
}
33-
github.issues.addLabels({
45+
46+
await github.issues.addLabels({
3447
owner: context.repo.owner,
3548
repo: context.repo.repo,
36-
issue_number: context.payload.issue.number,
37-
labels: labels
49+
issue_number,
50+
labels,
3851
});
3952
40-
- name: Assign Issue to Maintainer
53+
- name: Assign to PaulAndersonS (Issues only)
4154
if: github.event.issue != null
4255
uses: actions/github-script@v6
4356
with:
4457
script: |
45-
const title = context.payload.issue.title.toLowerCase();
46-
const assignees = [];
47-
// Replace these usernames with your repo's contributors or teams
48-
if (title.includes('bug')) {
49-
assignees.push('bug-fixer');
50-
} else if (title.includes('feature')) {
51-
assignees.push('feature-dev');
52-
} else if (title.includes('docs') || title.includes('documentation')) {
53-
assignees.push('docs-maintainer');
54-
}
55-
if (assignees.length > 0) {
56-
github.issues.addAssignees({
57-
owner: context.repo.owner,
58-
repo: context.repo.repo,
59-
issue_number: context.payload.issue.number,
60-
assignees: assignees
61-
});
62-
}
58+
await github.issues.addAssignees({
59+
owner: context.repo.owner,
60+
repo: context.repo.repo,
61+
issue_number: context.payload.issue.number,
62+
assignees: ['PaulAndersonS']
63+
});
6364
64-
- name: Add Thank You Comment on Issue
65+
- name: Add Comment (Issues)
6566
if: github.event.issue != null
6667
uses: actions/github-script@v6
6768
with:
@@ -78,38 +79,14 @@ jobs:
7879
type = 'question';
7980
}
8081
const comment = `Thank you for your ${type}! We will review it soon.`;
81-
github.issues.createComment({
82+
await github.issues.createComment({
8283
owner: context.repo.owner,
8384
repo: context.repo.repo,
8485
issue_number: context.payload.issue.number,
8586
body: comment
8687
});
8788
88-
- name: Assign Labels to PR
89-
if: github.event.pull_request != null
90-
uses: actions/github-script@v6
91-
with:
92-
script: |
93-
const title = context.payload.pull_request.title.toLowerCase();
94-
const body = context.payload.pull_request.body ? context.payload.pull_request.body.toLowerCase() : '';
95-
const labels = [];
96-
if (title.includes('bugfix') || body.includes('bugfix') || title.includes('fix') || body.includes('fix')) {
97-
labels.push('bug');
98-
} else if (title.includes('feature') || body.includes('feature') || title.includes('enhancement') || body.includes('enhancement')) {
99-
labels.push('enhancement');
100-
} else if (title.includes('docs') || body.includes('docs') || title.includes('documentation') || body.includes('documentation')) {
101-
labels.push('documentation');
102-
} else {
103-
labels.push('needs-triage');
104-
}
105-
github.issues.addLabels({
106-
owner: context.repo.owner,
107-
repo: context.repo.repo,
108-
issue_number: context.payload.pull_request.number,
109-
labels: labels
110-
});
111-
112-
- name: Add Thank You Comment on PR
89+
- name: Add Comment (Pull Requests)
11390
if: github.event.pull_request != null
11491
uses: actions/github-script@v6
11592
with:
@@ -124,7 +101,7 @@ jobs:
124101
type = 'documentation PR';
125102
}
126103
const comment = `Thank you for your ${type}! We will review it soon.`;
127-
github.issues.createComment({
104+
await github.issues.createComment({
128105
owner: context.repo.owner,
129106
repo: context.repo.repo,
130107
issue_number: context.payload.pull_request.number,

0 commit comments

Comments
 (0)