Skip to content

Commit 4677b21

Browse files
committed
Discord Integration
1 parent e6fde4a commit 4677b21

5 files changed

Lines changed: 828 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 278 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ on:
99
branches:
1010
- main
1111
workflow_dispatch:
12-
13-
12+
13+
env:
14+
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
1415

1516
jobs:
1617
backend-tests:
@@ -109,6 +110,106 @@ jobs:
109110
# Clean up
110111
kill $SERVER_PID
111112
113+
- name: Send Discord notification for backend success
114+
if: success()
115+
run: |
116+
curl -H "Content-Type: application/json" \
117+
-X POST \
118+
-d '{
119+
"embeds": [{
120+
"title": "✅ Backend Tests Passed",
121+
"description": "Backend tests for Node.js ${{ matrix.node-version }} completed successfully",
122+
"color": 3066993,
123+
"fields": [
124+
{
125+
"name": "Job",
126+
"value": "${{ github.job }}",
127+
"inline": true
128+
},
129+
{
130+
"name": "Node.js Version",
131+
"value": "${{ matrix.node-version }}",
132+
"inline": true
133+
},
134+
{
135+
"name": "Repository",
136+
"value": "${{ github.repository }}",
137+
"inline": true
138+
},
139+
{
140+
"name": "Branch",
141+
"value": "${{ github.ref_name }}",
142+
"inline": true
143+
},
144+
{
145+
"name": "Commit",
146+
"value": "[${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})",
147+
"inline": true
148+
},
149+
{
150+
"name": "Duration",
151+
"value": "Job completed at $(date -u)",
152+
"inline": false
153+
}
154+
],
155+
"timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'",
156+
"footer": {
157+
"text": "GitHub Actions"
158+
}
159+
}]
160+
}' \
161+
${{ env.DISCORD_WEBHOOK }}
162+
163+
- name: Send Discord notification for backend failure
164+
if: failure()
165+
run: |
166+
curl -H "Content-Type: application/json" \
167+
-X POST \
168+
-d '{
169+
"embeds": [{
170+
"title": "❌ Backend Tests Failed",
171+
"description": "Backend tests for Node.js ${{ matrix.node-version }} failed",
172+
"color": 15158332,
173+
"fields": [
174+
{
175+
"name": "Job",
176+
"value": "${{ github.job }}",
177+
"inline": true
178+
},
179+
{
180+
"name": "Node.js Version",
181+
"value": "${{ matrix.node-version }}",
182+
"inline": true
183+
},
184+
{
185+
"name": "Repository",
186+
"value": "${{ github.repository }}",
187+
"inline": true
188+
},
189+
{
190+
"name": "Branch",
191+
"value": "${{ github.ref_name }}",
192+
"inline": true
193+
},
194+
{
195+
"name": "Commit",
196+
"value": "[${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})",
197+
"inline": true
198+
},
199+
{
200+
"name": "View Logs",
201+
"value": "[Click here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})",
202+
"inline": false
203+
}
204+
],
205+
"timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'",
206+
"footer": {
207+
"text": "GitHub Actions"
208+
}
209+
}]
210+
}' \
211+
${{ env.DISCORD_WEBHOOK }}
212+
112213
frontend-tests:
113214
name: Frontend Tests (Node.js ${{ matrix.node-version }})
114215
runs-on: ubuntu-latest
@@ -176,6 +277,181 @@ jobs:
176277
# Clean up
177278
kill $SERVER_PID
178279
280+
- name: Send Discord notification for frontend success
281+
if: success()
282+
run: |
283+
curl -H "Content-Type: application/json" \
284+
-X POST \
285+
-d '{
286+
"embeds": [{
287+
"title": "✅ Frontend Tests Passed",
288+
"description": "Frontend tests for Node.js ${{ matrix.node-version }} completed successfully",
289+
"color": 3066993,
290+
"fields": [
291+
{
292+
"name": "Job",
293+
"value": "${{ github.job }}",
294+
"inline": true
295+
},
296+
{
297+
"name": "Node.js Version",
298+
"value": "${{ matrix.node-version }}",
299+
"inline": true
300+
},
301+
{
302+
"name": "Repository",
303+
"value": "${{ github.repository }}",
304+
"inline": true
305+
},
306+
{
307+
"name": "Branch",
308+
"value": "${{ github.ref_name }}",
309+
"inline": true
310+
},
311+
{
312+
"name": "Commit",
313+
"value": "[${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})",
314+
"inline": true
315+
},
316+
{
317+
"name": "Duration",
318+
"value": "Job completed at $(date -u)",
319+
"inline": false
320+
}
321+
],
322+
"timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'",
323+
"footer": {
324+
"text": "GitHub Actions"
325+
}
326+
}]
327+
}' \
328+
${{ env.DISCORD_WEBHOOK }}
329+
330+
- name: Send Discord notification for frontend failure
331+
if: failure()
332+
run: |
333+
curl -H "Content-Type: application/json" \
334+
-X POST \
335+
-d '{
336+
"embeds": [{
337+
"title": "❌ Frontend Tests Failed",
338+
"description": "Frontend tests for Node.js ${{ matrix.node-version }} failed",
339+
"color": 15158332,
340+
"fields": [
341+
{
342+
"name": "Job",
343+
"value": "${{ github.job }}",
344+
"inline": true
345+
},
346+
{
347+
"name": "Node.js Version",
348+
"value": "${{ matrix.node-version }}",
349+
"inline": true
350+
},
351+
{
352+
"name": "Repository",
353+
"value": "${{ github.repository }}",
354+
"inline": true
355+
},
356+
{
357+
"name": "Branch",
358+
"value": "${{ github.ref_name }}",
359+
"inline": true
360+
},
361+
{
362+
"name": "Commit",
363+
"value": "[${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})",
364+
"inline": true
365+
},
366+
{
367+
"name": "View Logs",
368+
"value": "[Click here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})",
369+
"inline": false
370+
}
371+
],
372+
"timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'",
373+
"footer": {
374+
"text": "GitHub Actions"
375+
}
376+
}]
377+
}' \
378+
${{ env.DISCORD_WEBHOOK }}
379+
380+
deployment-summary:
381+
name: Deployment Summary
382+
runs-on: ubuntu-latest
383+
needs: [backend-tests, frontend-tests]
384+
if: always()
385+
386+
steps:
387+
- name: Checkout code
388+
uses: actions/checkout@v4
389+
390+
- name: Send Discord deployment summary
391+
run: |
392+
BACKEND_STATUS="${{ needs.backend-tests.result }}"
393+
FRONTEND_STATUS="${{ needs.frontend-tests.result }}"
394+
395+
# Determine overall status and color
396+
if [[ "$BACKEND_STATUS" == "success" && "$FRONTEND_STATUS" == "success" ]]; then
397+
OVERALL_STATUS="success"
398+
COLOR=3066993
399+
TITLE="🎉 Deployment Complete - All Tests Passed"
400+
DESCRIPTION="All jobs completed successfully across all Node.js versions"
401+
else
402+
OVERALL_STATUS="failure"
403+
COLOR=15158332
404+
TITLE="❌ Deployment Issues Detected"
405+
DESCRIPTION="Some jobs failed. Please check the individual job results."
406+
fi
407+
408+
curl -H "Content-Type: application/json" \
409+
-X POST \
410+
-d '{
411+
"embeds": [{
412+
"title": "'"$TITLE"'",
413+
"description": "'"$DESCRIPTION"'",
414+
"color": '"$COLOR"',
415+
"fields": [
416+
{
417+
"name": "Backend Tests",
418+
"value": "'"$BACKEND_STATUS"'",
419+
"inline": true
420+
},
421+
{
422+
"name": "Frontend Tests",
423+
"value": "'"$FRONTEND_STATUS"'",
424+
"inline": true
425+
},
426+
{
427+
"name": "Repository",
428+
"value": "${{ github.repository }}",
429+
"inline": true
430+
},
431+
{
432+
"name": "Branch",
433+
"value": "${{ github.ref_name }}",
434+
"inline": true
435+
},
436+
{
437+
"name": "Commit",
438+
"value": "[${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})",
439+
"inline": true
440+
},
441+
{
442+
"name": "Workflow Run",
443+
"value": "[View Details](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})",
444+
"inline": true
445+
}
446+
],
447+
"timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'",
448+
"footer": {
449+
"text": "GitHub Actions CI/CD Pipeline"
450+
}
451+
}]
452+
}' \
453+
${{ env.DISCORD_WEBHOOK }}
454+
179455
180456

181457

0 commit comments

Comments
 (0)