Skip to content

Commit a792d12

Browse files
Update triage.yml
1 parent 1cdb5e0 commit a792d12

File tree

1 file changed

+88
-22
lines changed

1 file changed

+88
-22
lines changed

.github/workflows/triage.yml

Lines changed: 88 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,65 +11,131 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- name: Assign Labels
15-
if: github.event.issue
14+
- name: Assign Labels to Issue
15+
if: github.event.issue != null
1616
uses: actions/github-script@v6
1717
with:
1818
script: |
19-
const issue = context.issue;
19+
const title = context.payload.issue.title.toLowerCase();
20+
const body = context.payload.issue.body ? context.payload.issue.body.toLowerCase() : '';
2021
const labels = [];
21-
if (issue.title.includes('bug')) {
22+
if (title.includes('bug') || body.includes('bug') || title.includes('error') || body.includes('error') || title.includes('problem') || body.includes('problem')) {
2223
labels.push('bug');
23-
} else if (issue.title.includes('feature')) {
24+
} else if (title.includes('feature') || body.includes('feature') || title.includes('request') || body.includes('request') || title.includes('suggestion') || body.includes('suggestion') || title.includes('improvement') || body.includes('improvement')) {
2425
labels.push('enhancement');
26+
} else if (title.includes('docs') || body.includes('docs') || title.includes('documentation') || body.includes('documentation')) {
27+
labels.push('documentation');
28+
} else if (title.includes('question') || body.includes('question')) {
29+
labels.push('question');
2530
} else {
2631
labels.push('needs-triage');
2732
}
2833
github.issues.addLabels({
2934
owner: context.repo.owner,
3035
repo: context.repo.repo,
31-
issue_number: issue.number,
36+
issue_number: context.payload.issue.number,
3237
labels: labels
3338
});
3439
35-
- name: Assign Issues
36-
if: github.event.issue
40+
- name: Assign Issue to Maintainer
41+
if: github.event.issue != null
3742
uses: actions/github-script@v6
3843
with:
3944
script: |
40-
const issue = context.issue;
45+
const title = context.payload.issue.title.toLowerCase();
4146
const assignees = [];
42-
if (issue.title.includes('bug')) {
47+
// Replace these usernames with your repo's contributors or teams
48+
if (title.includes('bug')) {
4349
assignees.push('bug-fixer');
44-
} else if (issue.title.includes('feature')) {
50+
} else if (title.includes('feature')) {
4551
assignees.push('feature-dev');
52+
} else if (title.includes('docs') || title.includes('documentation')) {
53+
assignees.push('docs-maintainer');
4654
}
47-
github.issues.addAssignees({
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+
}
63+
64+
- name: Add Thank You Comment on Issue
65+
if: github.event.issue != null
66+
uses: actions/github-script@v6
67+
with:
68+
script: |
69+
const title = context.payload.issue.title.toLowerCase();
70+
let type = 'issue';
71+
if (title.includes('bug')) {
72+
type = 'bug report';
73+
} else if (title.includes('feature')) {
74+
type = 'feature request';
75+
} else if (title.includes('docs') || title.includes('documentation')) {
76+
type = 'documentation update';
77+
} else if (title.includes('question')) {
78+
type = 'question';
79+
}
80+
const comment = `Thank you for your ${type}! We will review it soon.`;
81+
github.issues.createComment({
82+
owner: context.repo.owner,
83+
repo: context.repo.repo,
84+
issue_number: context.payload.issue.number,
85+
body: comment
86+
});
87+
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({
48106
owner: context.repo.owner,
49107
repo: context.repo.repo,
50-
issue_number: issue.number,
51-
assignees: assignees
108+
issue_number: context.payload.pull_request.number,
109+
labels: labels
52110
});
53111
54-
- name: Add Comment
55-
if: github.event.issue
112+
- name: Add Thank You Comment on PR
113+
if: github.event.pull_request != null
56114
uses: actions/github-script@v6
57115
with:
58116
script: |
59-
const issue = context.issue;
60-
const comment = `Thank you for your ${issue.title.includes('bug') ? 'bug report' : 'feature request'}! We will review it soon.`;
117+
const title = context.payload.pull_request.title.toLowerCase();
118+
let type = 'pull request';
119+
if (title.includes('bugfix') || title.includes('fix')) {
120+
type = 'bug fix PR';
121+
} else if (title.includes('feature')) {
122+
type = 'feature PR';
123+
} else if (title.includes('docs') || title.includes('documentation')) {
124+
type = 'documentation PR';
125+
}
126+
const comment = `Thank you for your ${type}! We will review it soon.`;
61127
github.issues.createComment({
62128
owner: context.repo.owner,
63129
repo: context.repo.repo,
64-
issue_number: issue.number,
130+
issue_number: context.payload.pull_request.number,
65131
body: comment
66132
});
67133
68-
- name: Close Stale Issues
134+
- name: Close Stale Issues and PRs
69135
uses: actions/stale@v4
70136
with:
71137
repo-token: ${{ secrets.GITHUB_TOKEN }}
72138
stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.'
73139
stale-pr-message: 'This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.'
74-
days-before-stale: 30
75-
days-before-close: 7
140+
days-before-stale: 60
141+
days-before-close: 14

0 commit comments

Comments
 (0)