-
Notifications
You must be signed in to change notification settings - Fork 0
223 lines (200 loc) · 10.1 KB
/
auto-label-issues.yml
File metadata and controls
223 lines (200 loc) · 10.1 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
name: 🏷️ Auto Label Issues
on:
issues:
types: [opened, edited, reopened]
issue_comment:
types: [created]
permissions:
issues: write
contents: read
jobs:
auto-label:
runs-on: ubuntu-latest
steps:
- name: Label Bug Reports
if: success() && github.event.issue && contains(github.event.issue.title, '[BUG]') && (github.event.action == 'opened' || github.event.action == 'edited' || github.event.action == 'created' || github.event.action == 'reopened')
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['bug', 'needs-triage']
});
console.log('Added bug labels successfully');
} catch (error) {
console.error('Error adding bug labels:', error);
}
- name: Label Feature Requests
if: success() && github.event.issue && contains(github.event.issue.title, '[FEATURE]') && (github.event.action == 'opened' || github.event.action == 'edited' || github.event.action == 'created' || github.event.action == 'reopened')
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['enhancement', 'needs-review']
});
console.log('Added feature labels successfully');
} catch (error) {
console.error('Error adding feature labels:', error);
}
- name: Label Deployment Tasks
if: success() && github.event.issue && contains(github.event.issue.title, '[DEPLOY]') && (github.event.action == 'opened' || github.event.action == 'edited' || github.event.action == 'created' || github.event.action == 'reopened')
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['deployment', 'high-priority']
});
console.log('Added deployment labels successfully');
} catch (error) {
console.error('Error adding deployment labels:', error);
}
- name: Label Critical Issues
if: success() && github.event.issue && github.event.issue.body && (contains(github.event.issue.body, 'Critical') || contains(github.event.issue.body, 'Must Have') || contains(github.event.issue.body, 'wedding day') || contains(github.event.issue.body, 'URGENT'))
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
const labels = ['critical', 'urgent'];
// Check for wedding day criticality
if (context.payload.issue.body.toLowerCase().includes('wedding day') ||
context.payload.issue.body.toLowerCase().includes('before wedding day')) {
labels.push('wedding-day-critical');
}
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labels
});
console.log('Added critical labels successfully:', labels);
} catch (error) {
console.error('Error adding critical labels:', error);
}
- name: Auto-assign Critical Issues
if: success() && github.event.issue && (contains(github.event.issue.title, '[DEPLOY]') || (github.event.issue.body && (contains(github.event.issue.body, 'Critical') || contains(github.event.issue.body, 'wedding day'))))
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
await github.rest.issues.addAssignees({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
assignees: ['syed-reza98']
});
console.log('Auto-assigned to syed-reza98 successfully');
} catch (error) {
console.error('Error auto-assigning:', error);
}
- name: Add Wedding Day Priority Labels
if: success() && github.event.issue && github.event.issue.body && (contains(github.event.issue.body, 'Before Wedding Day') || contains(github.event.issue.body, 'wedding day') || contains(github.event.issue.body, 'Wedding Day'))
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['wedding-day-critical']
});
console.log('Added wedding-day-critical label successfully');
} catch (error) {
console.error('Error adding wedding-day-critical label:', error);
}
- name: Add Priority Based on Keywords
if: success() && github.event.issue && github.event.issue.body
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
const body = context.payload.issue.body.toLowerCase();
const title = context.payload.issue.title.toLowerCase();
const labels = [];
// High priority keywords
if (body.includes('production') || body.includes('live') ||
body.includes('blocking') || body.includes('urgent') ||
title.includes('urgent') || title.includes('critical')) {
labels.push('high-priority');
}
// Mobile-specific issues
if (body.includes('mobile') || body.includes('iphone') ||
body.includes('android') || body.includes('responsive')) {
labels.push('mobile');
}
// UI/UX issues
if (body.includes('ui') || body.includes('ux') ||
body.includes('design') || body.includes('layout')) {
labels.push('ui-ux');
}
// Performance issues
if (body.includes('slow') || body.includes('performance') ||
body.includes('loading') || body.includes('speed')) {
labels.push('performance');
}
if (labels.length > 0) {
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labels
});
console.log('Added priority/category labels successfully:', labels);
}
} catch (error) {
console.error('Error adding priority labels:', error);
}
- name: Comment on Critical Issues
if: success() && github.event.issue && (github.event.action == 'opened' || github.event.action == 'created') && github.event.issue.body && (contains(github.event.issue.body, 'Critical') || contains(github.event.issue.body, 'wedding day') || contains(github.event.issue.title, '[DEPLOY]'))
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
const isCritical = context.payload.issue.body.toLowerCase().includes('critical');
const isWeddingDay = context.payload.issue.body.toLowerCase().includes('wedding day');
const isDeployment = context.payload.issue.title.includes('[DEPLOY]');
let message = '🚨 **High Priority Issue Detected**\n\n';
if (isWeddingDay) {
message = '💒 **Wedding Day Critical Issue**\n\n';
message += 'This issue affects wedding day functionality and requires immediate attention!\n\n';
} else if (isCritical) {
message = '🚨 **Critical Issue Detected**\n\n';
message += 'This issue has been marked as critical and requires immediate attention.\n\n';
} else if (isDeployment) {
message = '🚀 **Deployment Task**\n\n';
message += 'This deployment task has been flagged for priority handling.\n\n';
}
message += `@syed-reza98 has been automatically assigned.\n\n**Next Steps:**\n- [ ] Investigate and assess impact\n- [ ] Create action plan\n- [ ] Implement fix\n- [ ] Test and validate\n- [ ] Deploy if necessary\n\n`;
if (isWeddingDay) {
message += '**Emergency Contacts:**\n- Primary: codestromhub@gmail.com\n- Phone: +880 1234-567890\n\n';
}
message += '*This is an automated message from the [Sharothee Wedding Project Management System](https://github.com/users/syed-reza98/projects/5).*';
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: message
});
console.log('Added critical issue comment successfully');
} catch (error) {
console.error('Error adding critical issue comment:', error);
}