@@ -2,7 +2,9 @@ name: 🏷️ Auto Label Issues
22
33on :
44 issues :
5- types : [opened, edited]
5+ types : [opened, edited, reopened]
6+ issue_comment :
7+ types : [created]
68
79permissions :
810 issues : write
@@ -13,85 +15,209 @@ jobs:
1315 runs-on : ubuntu-latest
1416 steps :
1517 - name : Label Bug Reports
16- if : contains(github.event.issue.title, '[BUG]')
18+ 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 ')
1719 uses : actions/github-script@v7
1820 with :
21+ github-token : ${{ secrets.GITHUB_TOKEN }}
1922 script : |
20- github.rest.issues.addLabels({
21- issue_number: context.issue.number,
22- owner: context.repo.owner,
23- repo: context.repo.repo,
24- labels: ['bug', 'needs-triage']
25- })
23+ try {
24+ await github.rest.issues.addLabels({
25+ issue_number: context.issue.number,
26+ owner: context.repo.owner,
27+ repo: context.repo.repo,
28+ labels: ['bug', 'needs-triage']
29+ });
30+ console.log('Added bug labels successfully');
31+ } catch (error) {
32+ console.error('Error adding bug labels:', error);
33+ }
2634
2735 - name : Label Feature Requests
28- if : contains(github.event.issue.title, '[FEATURE]')
36+ 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 ')
2937 uses : actions/github-script@v7
3038 with :
39+ github-token : ${{ secrets.GITHUB_TOKEN }}
3140 script : |
32- github.rest.issues.addLabels({
33- issue_number: context.issue.number,
34- owner: context.repo.owner,
35- repo: context.repo.repo,
36- labels: ['enhancement', 'needs-review']
37- })
41+ try {
42+ await github.rest.issues.addLabels({
43+ issue_number: context.issue.number,
44+ owner: context.repo.owner,
45+ repo: context.repo.repo,
46+ labels: ['enhancement', 'needs-review']
47+ });
48+ console.log('Added feature labels successfully');
49+ } catch (error) {
50+ console.error('Error adding feature labels:', error);
51+ }
3852
3953 - name : Label Deployment Tasks
40- if : contains(github.event.issue.title, '[DEPLOY]')
54+ 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 ')
4155 uses : actions/github-script@v7
4256 with :
57+ github-token : ${{ secrets.GITHUB_TOKEN }}
4358 script : |
44- github.rest.issues.addLabels({
45- issue_number: context.issue.number,
46- owner: context.repo.owner,
47- repo: context.repo.repo,
48- labels: ['deployment', 'high-priority']
49- })
59+ try {
60+ await github.rest.issues.addLabels({
61+ issue_number: context.issue.number,
62+ owner: context.repo.owner,
63+ repo: context.repo.repo,
64+ labels: ['deployment', 'high-priority']
65+ });
66+ console.log('Added deployment labels successfully');
67+ } catch (error) {
68+ console.error('Error adding deployment labels:', error);
69+ }
5070
5171 - name : Label Critical Issues
52- if : contains(github.event.issue.body, 'Critical') || contains(github.event.issue.body, 'Must Have')
72+ 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') )
5373 uses : actions/github-script@v7
5474 with :
75+ github-token : ${{ secrets.GITHUB_TOKEN }}
5576 script : |
56- github.rest.issues.addLabels({
57- issue_number: context.issue.number,
58- owner: context.repo.owner,
59- repo: context.repo.repo,
60- labels: ['critical', 'urgent']
61- })
77+ try {
78+ const labels = ['critical', 'urgent'];
79+
80+ // Check for wedding day criticality
81+ if (context.payload.issue.body.toLowerCase().includes('wedding day') ||
82+ context.payload.issue.body.toLowerCase().includes('before wedding day')) {
83+ labels.push('wedding-day-critical');
84+ }
85+
86+ await github.rest.issues.addLabels({
87+ issue_number: context.issue.number,
88+ owner: context.repo.owner,
89+ repo: context.repo.repo,
90+ labels: labels
91+ });
92+ console.log('Added critical labels successfully:', labels);
93+ } catch (error) {
94+ console.error('Error adding critical labels:', error);
95+ }
6296
63- - name : Auto-assign to Owner
64- if : contains(github.event.issue.labels.*.name , 'critical ') || contains(github.event.issue.title , '[DEPLOY]' )
97+ - name : Auto-assign Critical Issues
98+ 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'))) )
6599 uses : actions/github-script@v7
66100 with :
101+ github-token : ${{ secrets.GITHUB_TOKEN }}
67102 script : |
68- github.rest.issues.addAssignees({
69- issue_number: context.issue.number,
70- owner: context.repo.owner,
71- repo: context.repo.repo,
72- assignees: ['syed-reza98']
73- })
103+ try {
104+ await github.rest.issues.addAssignees({
105+ issue_number: context.issue.number,
106+ owner: context.repo.owner,
107+ repo: context.repo.repo,
108+ assignees: ['syed-reza98']
109+ });
110+ console.log('Auto-assigned to syed-reza98 successfully');
111+ } catch (error) {
112+ console.error('Error auto-assigning:', error);
113+ }
74114
75- - name : Add Wedding Day Priority
76- if : contains(github.event.issue.body, 'Before Wedding Day') || contains(github.event.issue.body, 'wedding day')
115+ - name : Add Wedding Day Priority Labels
116+ 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') )
77117 uses : actions/github-script@v7
78118 with :
119+ github-token : ${{ secrets.GITHUB_TOKEN }}
79120 script : |
80- github.rest.issues.addLabels({
81- issue_number: context.issue.number,
82- owner: context.repo.owner,
83- repo: context.repo.repo,
84- labels: ['wedding-day-critical']
85- })
121+ try {
122+ await github.rest.issues.addLabels({
123+ issue_number: context.issue.number,
124+ owner: context.repo.owner,
125+ repo: context.repo.repo,
126+ labels: ['wedding-day-critical']
127+ });
128+ console.log('Added wedding-day-critical label successfully');
129+ } catch (error) {
130+ console.error('Error adding wedding-day-critical label:', error);
131+ }
132+
133+ - name : Add Priority Based on Keywords
134+ if : success() && github.event.issue && github.event.issue.body
135+ uses : actions/github-script@v7
136+ with :
137+ github-token : ${{ secrets.GITHUB_TOKEN }}
138+ script : |
139+ try {
140+ const body = context.payload.issue.body.toLowerCase();
141+ const title = context.payload.issue.title.toLowerCase();
142+ const labels = [];
143+
144+ // High priority keywords
145+ if (body.includes('production') || body.includes('live') ||
146+ body.includes('blocking') || body.includes('urgent') ||
147+ title.includes('urgent') || title.includes('critical')) {
148+ labels.push('high-priority');
149+ }
150+
151+ // Mobile-specific issues
152+ if (body.includes('mobile') || body.includes('iphone') ||
153+ body.includes('android') || body.includes('responsive')) {
154+ labels.push('mobile');
155+ }
156+
157+ // UI/UX issues
158+ if (body.includes('ui') || body.includes('ux') ||
159+ body.includes('design') || body.includes('layout')) {
160+ labels.push('ui-ux');
161+ }
162+
163+ // Performance issues
164+ if (body.includes('slow') || body.includes('performance') ||
165+ body.includes('loading') || body.includes('speed')) {
166+ labels.push('performance');
167+ }
168+
169+ if (labels.length > 0) {
170+ await github.rest.issues.addLabels({
171+ issue_number: context.issue.number,
172+ owner: context.repo.owner,
173+ repo: context.repo.repo,
174+ labels: labels
175+ });
176+ console.log('Added priority/category labels successfully:', labels);
177+ }
178+ } catch (error) {
179+ console.error('Error adding priority labels:', error);
180+ }
86181
87182 - name : Comment on Critical Issues
88- if : contains(github.event.issue.labels.*.name , 'critical' )
183+ 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]') )
89184 uses : actions/github-script@v7
90185 with :
186+ github-token : ${{ secrets.GITHUB_TOKEN }}
91187 script : |
92- github.rest.issues.createComment({
93- issue_number: context.issue.number,
94- owner: context.repo.owner,
95- repo: context.repo.repo,
96- body: '🚨 **Critical Issue Detected**\n\nThis issue has been marked as critical and requires immediate attention. @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*This is an automated message from the Sharothee Wedding Project Management System.*'
97- })
188+ try {
189+ const isCritical = context.payload.issue.body.toLowerCase().includes('critical');
190+ const isWeddingDay = context.payload.issue.body.toLowerCase().includes('wedding day');
191+ const isDeployment = context.payload.issue.title.includes('[DEPLOY]');
192+
193+ let message = '🚨 **High Priority Issue Detected**\n\n';
194+
195+ if (isWeddingDay) {
196+ message = '💒 **Wedding Day Critical Issue**\n\n';
197+ message += 'This issue affects wedding day functionality and requires immediate attention!\n\n';
198+ } else if (isCritical) {
199+ message = '🚨 **Critical Issue Detected**\n\n';
200+ message += 'This issue has been marked as critical and requires immediate attention.\n\n';
201+ } else if (isDeployment) {
202+ message = '🚀 **Deployment Task**\n\n';
203+ message += 'This deployment task has been flagged for priority handling.\n\n';
204+ }
205+
206+ 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`;
207+
208+ if (isWeddingDay) {
209+ message += '**Emergency Contacts:**\n- Primary: codestromhub@gmail.com\n- Phone: +880 1234-567890\n\n';
210+ }
211+
212+ message += '*This is an automated message from the [Sharothee Wedding Project Management System](https://github.com/users/syed-reza98/projects/5).*';
213+
214+ await github.rest.issues.createComment({
215+ issue_number: context.issue.number,
216+ owner: context.repo.owner,
217+ repo: context.repo.repo,
218+ body: message
219+ });
220+ console.log('Added critical issue comment successfully');
221+ } catch (error) {
222+ console.error('Error adding critical issue comment:', error);
223+ }
0 commit comments