Skip to content

Commit 8640a70

Browse files
author
Fr4gm3nt3d_sh
committed
Update .github/workflows/llmcodereview.yml
Update design, adjust Prompt
1 parent 686b92b commit 8640a70

File tree

1 file changed

+320
-43
lines changed

1 file changed

+320
-43
lines changed

.github/workflows/llmcodereview.yml

Lines changed: 320 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ on:
99
jobs:
1010
gemini-report:
1111
runs-on: ubuntu-latest
12-
permissions:
13-
contents: write
1412

1513
steps:
1614
- name: Checkout repo
@@ -41,69 +39,348 @@ jobs:
4139
const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY);
4240
const model = genAI.getGenerativeModel({ model: "gemini-2.5-flash" });
4341
44-
const prompt = `
45-
Analyze the following git diff.
46-
List:
47-
- Issues found
48-
- Severity
49-
- Proposed fixes
42+
const prompt = `You are a code review expert. Analyze the following git diff and provide a detailed code review.
5043
51-
Return clean markdown.
52-
Diff:
53-
${diff}
54-
`;
44+
Focus on:
45+
- Potential bugs or logical errors in the NEW code
46+
- Performance issues and optimization opportunities
47+
- Security vulnerabilities
48+
- Code style and maintainability improvements
49+
- Edge cases that might not be handled
50+
- If the old code had a better approach to solving the same problem, mention it
51+
52+
Be constructive and specific. For each issue, explain:
53+
1. What the problem is
54+
2. Why it matters
55+
3. How to fix it with concrete code examples
56+
57+
Return the review in clean, well-formatted markdown with sections and code blocks.
58+
59+
Git Diff:
60+
\`\`\`
61+
${diff}
62+
\`\`\``;
5563

5664
const result = await model.generateContent(prompt);
5765
const report = result.response.text();
5866

5967
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
6068
const reportName = `report-${timestamp}.html`;
69+
const date = new Date();
70+
71+
const html = `<!DOCTYPE html>
72+
<html lang="en">
73+
<head>
74+
<meta charset="UTF-8">
75+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
76+
<title>Gemini Code Review - ${reportName}</title>
77+
<style>
78+
* {
79+
margin: 0;
80+
padding: 0;
81+
box-sizing: border-box;
82+
}
83+
84+
body {
85+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
86+
line-height: 1.6;
87+
color: #333;
88+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
89+
min-height: 100vh;
90+
padding: 2rem 1rem;
91+
}
92+
93+
.container {
94+
max-width: 900px;
95+
margin: 0 auto;
96+
background: white;
97+
border-radius: 12px;
98+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
99+
overflow: hidden;
100+
}
101+
102+
.header {
103+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
104+
color: white;
105+
padding: 3rem 2rem;
106+
text-align: center;
107+
}
108+
109+
.header h1 {
110+
font-size: 2.5rem;
111+
margin-bottom: 0.5rem;
112+
font-weight: 700;
113+
}
114+
115+
.header p {
116+
font-size: 1.1rem;
117+
opacity: 0.95;
118+
}
119+
120+
.timestamp {
121+
font-size: 0.9rem;
122+
opacity: 0.85;
123+
margin-top: 1rem;
124+
}
125+
126+
.content {
127+
padding: 3rem 2rem;
128+
}
129+
130+
.content h2 {
131+
color: #667eea;
132+
margin-top: 2rem;
133+
margin-bottom: 1rem;
134+
font-size: 1.8rem;
135+
border-left: 4px solid #667eea;
136+
padding-left: 1rem;
137+
}
138+
139+
.content h3 {
140+
color: #764ba2;
141+
margin-top: 1.5rem;
142+
margin-bottom: 0.8rem;
143+
font-size: 1.3rem;
144+
}
145+
146+
.content h4 {
147+
color: #555;
148+
margin-top: 1rem;
149+
margin-bottom: 0.5rem;
150+
font-size: 1.1rem;
151+
}
152+
153+
.content p {
154+
margin-bottom: 1rem;
155+
text-align: justify;
156+
}
157+
158+
.content ul, .content ol {
159+
margin-left: 2rem;
160+
margin-bottom: 1rem;
161+
}
162+
163+
.content li {
164+
margin-bottom: 0.5rem;
165+
}
166+
167+
.content code {
168+
background: #f5f5f5;
169+
padding: 0.2rem 0.5rem;
170+
border-radius: 4px;
171+
font-family: 'Monaco', 'Courier New', monospace;
172+
font-size: 0.9rem;
173+
color: #e83e8c;
174+
}
175+
176+
.content pre {
177+
background: #2d2d2d;
178+
color: #f8f8f2;
179+
padding: 1.5rem;
180+
border-radius: 8px;
181+
overflow-x: auto;
182+
margin: 1rem 0;
183+
font-family: 'Monaco', 'Courier New', monospace;
184+
font-size: 0.9rem;
185+
line-height: 1.5;
186+
}
187+
188+
.content pre code {
189+
background: none;
190+
padding: 0;
191+
color: inherit;
192+
}
193+
194+
.footer {
195+
background: #f9f9f9;
196+
padding: 2rem;
197+
text-align: center;
198+
color: #666;
199+
border-top: 1px solid #eee;
200+
}
61201

62-
const html = `
63-
<html>
64-
<head>
65-
<title>${reportName}</title>
66-
<style>
67-
body { font-family: sans-serif; padding: 2rem; }
68-
pre { white-space: pre-wrap; }
69-
</style>
70-
</head>
71-
<body>
72-
<h1>Gemini Code Report</h1>
73-
<p>${new Date().toUTCString()}</p>
74-
<pre>${report}</pre>
75-
</body>
76-
</html>
77-
`;
202+
.footer a {
203+
color: #667eea;
204+
text-decoration: none;
205+
}
206+
207+
.footer a:hover {
208+
text-decoration: underline;
209+
}
210+
211+
@media (max-width: 768px) {
212+
.header h1 {
213+
font-size: 1.8rem;
214+
}
215+
216+
.content {
217+
padding: 1.5rem 1rem;
218+
}
219+
220+
.container {
221+
margin: 0;
222+
border-radius: 0;
223+
}
224+
}
225+
</style>
226+
</head>
227+
<body>
228+
<div class="container">
229+
<div class="header">
230+
<h1>🔍 Gemini Code Review</h1>
231+
<p>Automated code analysis and recommendations</p>
232+
<p class="timestamp">${date.toUTCString()}</p>
233+
</div>
234+
235+
<div class="content">
236+
${report}
237+
</div>
238+
239+
<div class="footer">
240+
<p>Generated by Gemini Code Analysis | <a href="index.html">← Back to Reports</a></p>
241+
</div>
242+
</div>
243+
</body>
244+
</html>`;
78245

79246
fs.writeFileSync(reportName, html);
80247

81248
let index = "";
82249
if (fs.existsSync("report.html")) {
83250
index = fs.readFileSync("report.html", "utf8");
84251
} else {
85-
index = `
86-
<html>
87-
<head>
88-
<title>Reports</title>
89-
</head>
90-
<body>
91-
<h1>Gemini Reports</h1>
92-
<div id="reports"></div>
93-
</body>
94-
</html>
95-
`;
252+
index = `<!DOCTYPE html>
253+
<html lang="en">
254+
<head>
255+
<meta charset="UTF-8">
256+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
257+
<title>Gemini Code Reports</title>
258+
<style>
259+
* {
260+
margin: 0;
261+
padding: 0;
262+
box-sizing: border-box;
263+
}
264+
265+
body {
266+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
267+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
268+
min-height: 100vh;
269+
padding: 2rem 1rem;
270+
}
271+
272+
.container {
273+
max-width: 900px;
274+
margin: 0 auto;
275+
}
276+
277+
.header {
278+
text-align: center;
279+
color: white;
280+
margin-bottom: 3rem;
281+
}
282+
283+
.header h1 {
284+
font-size: 3rem;
285+
margin-bottom: 0.5rem;
286+
font-weight: 700;
287+
}
288+
289+
.header p {
290+
font-size: 1.2rem;
291+
opacity: 0.95;
292+
}
293+
294+
.reports-grid {
295+
display: grid;
296+
gap: 1.5rem;
297+
margin-top: 2rem;
298+
}
299+
300+
.report-card {
301+
background: white;
302+
border-radius: 12px;
303+
padding: 1.5rem;
304+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
305+
transition: transform 0.3s ease, box-shadow 0.3s ease;
306+
text-decoration: none;
307+
color: inherit;
308+
display: block;
309+
}
310+
311+
.report-card:hover {
312+
transform: translateY(-5px);
313+
box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
314+
}
315+
316+
.report-card h2 {
317+
color: #667eea;
318+
margin-bottom: 0.5rem;
319+
font-size: 1.3rem;
320+
}
321+
322+
.report-card .date {
323+
color: #999;
324+
font-size: 0.9rem;
325+
}
326+
327+
.report-card p {
328+
color: #666;
329+
margin-top: 0.5rem;
330+
font-size: 0.95rem;
331+
}
332+
333+
.empty {
334+
text-align: center;
335+
color: white;
336+
padding: 3rem;
337+
}
338+
339+
.empty h2 {
340+
font-size: 1.5rem;
341+
margin-bottom: 1rem;
342+
}
343+
344+
@media (max-width: 768px) {
345+
.header h1 {
346+
font-size: 2rem;
347+
}
348+
349+
body {
350+
padding: 1rem;
351+
}
352+
}
353+
</style>
354+
</head>
355+
<body>
356+
<div class="container">
357+
<div class="header">
358+
<h1>📊 Gemini Code Reviews</h1>
359+
<p>Continuous code analysis and insights</p>
360+
</div>
361+
362+
<div class="reports-grid" id="reports"></div>
363+
</div>
364+
365+
<script>
366+
const reportsDiv = document.getElementById('reports');
367+
if (reportsDiv.innerHTML.trim() === '') {
368+
reportsDiv.innerHTML = '<div class="empty"><h2>No reports yet</h2><p>Code reviews will appear here as you push changes.</p></div>';
369+
}
370+
</script>
371+
</body>
372+
</html>`;
96373
}
97374

98-
const button = `<p><a href="./${reportName}">${reportName}</a></p>`;
375+
const button = `<a href="./${reportName}" class="report-card"><h2>📝 Code Review Report</h2><p class="date">${date.toUTCString()}</p></a>`;
99376
index = index.replace(
100-
'<div id="reports">',
101-
`<div id="reports">\n${button}`
377+
'<div class="reports-grid" id="reports">',
378+
`<div class="reports-grid" id="reports">\n${button}`
102379
);
103380

104381
fs.writeFileSync("report.html", index);
105382

106-
console.log("=== Gemini Conclusion ===");
383+
console.log("=== Gemini Code Review Complete ===");
107384
console.log(report);
108385
EOF
109386

0 commit comments

Comments
 (0)