1- module . exports = async ( { github, context, backend, mobile, web } ) => {
1+ module . exports = async ( {
2+ github,
3+ context,
4+ backend,
5+ mobile,
6+ web,
7+ backendLint,
8+ backendTest,
9+ backendTypecheck,
10+ mobileLint,
11+ mobileTest,
12+ webCheck,
13+ webBuild
14+ } ) => {
215 const owner = context . repo . owner ;
316 const repo = context . repo . repo ;
4- const pr = context . payload . pull_request ;
5- const prNumber = pr . number ;
17+ const prNumber = context . payload . pull_request . number ;
618
7- const statusEmoji = ( status ) => {
19+ const emoji = ( status ) => {
820 if ( status === 'success' ) return '✅' ;
921 if ( status === 'failure' ) return '❌' ;
1022 if ( status === 'skipped' ) return '⏭️' ;
1123 return '⚪' ;
1224 } ;
1325
14- const statusLabel = ( status ) => {
15- if ( status === 'skipped' ) return ` ${ statusEmoji ( status ) } Skipped — no changes detected` ;
16- return `${ statusEmoji ( status ) } ${ status } ` ;
26+ const label = ( status ) => {
27+ if ( ! status ) return '⚪ unknown' ;
28+ return `${ emoji ( status ) } ${ status } ` ;
1729 } ;
1830
19- const results = [ backend , mobile , web ] ;
20- const allSkipped = results . every ( ( s ) => s === 'skipped' ) ;
21- const anyFailure = results . some ( ( s ) => s === 'failure' ) ;
22- const allPassed = results . every ( ( s ) => s === 'success' || s === 'skipped' ) ;
31+ const anyFailure = [
32+ backend ,
33+ mobile ,
34+ web
35+ ] . includes ( 'failure' ) ;
2336
24- let title ;
25- if ( allSkipped ) {
26- title = '⏭️ No changes detected — all checks skipped' ;
27- } else if ( anyFailure ) {
28- title = '❌ Some checks failed' ;
29- } else if ( allPassed ) {
30- title = '✅ All checks passed' ;
31- } else {
32- title = '⚪ Checks completed' ;
33- }
37+ const title = anyFailure
38+ ? '❌ Some checks failed'
39+ : '✅ CI completed' ;
3440
3541 const timestamp = new Date ( ) . toUTCString ( ) ;
3642
3743 const body = `## CI Results — ${ title }
3844
45+ ### 🖥️ Backend (${ label ( backend ) } )
3946| Check | Status |
4047|---|---|
41- | 🖥️ Backend | ${ statusLabel ( backend ) } |
42- | 📱 Mobile | ${ statusLabel ( mobile ) } |
43- | 🌐 Web | ${ statusLabel ( web ) } |
48+ | Lint | ${ label ( backendLint ) } |
49+ | Test | ${ label ( backendTest ) } |
50+ | Typecheck | ${ label ( backendTypecheck ) } |
4451
45- > ⏭️ **Skipped** means no files were changed in that area — the check was not needed.
52+ ### 📱 Mobile (${ label ( mobile ) } )
53+ | Check | Status |
54+ |---|---|
55+ | Lint | ${ label ( mobileLint ) } |
56+ | Test | ${ label ( mobileTest ) } |
57+
58+ ### 🌐 Web (${ label ( web ) } )
59+ | Check | Status |
60+ |---|---|
61+ | Check | ${ label ( webCheck ) } |
62+ | Build | ${ label ( webBuild ) } |
4663
4764---
4865🕐 Last updated: \`${ timestamp } \`` ;
4966
5067 const COMMENT_MARKER = '## CI Results —' ;
5168
5269 try {
53- const comments = await github . paginate ( github . rest . issues . listComments , {
54- owner,
55- repo,
56- issue_number : prNumber ,
57- } ) ;
70+ const comments = await github . paginate (
71+ github . rest . issues . listComments ,
72+ {
73+ owner,
74+ repo,
75+ issue_number : prNumber
76+ }
77+ ) ;
5878
59- const existingComment = comments . find (
60- ( c ) => c . body && c . body . startsWith ( COMMENT_MARKER )
79+ const existing = comments . find (
80+ c => c . body && c . body . startsWith ( COMMENT_MARKER )
6181 ) ;
6282
63- if ( existingComment ) {
83+ if ( existing ) {
6484 await github . rest . issues . updateComment ( {
6585 owner,
6686 repo,
67- comment_id : existingComment . id ,
68- body,
87+ comment_id : existing . id ,
88+ body
6989 } ) ;
70- console . log ( `Updated existing comment: ${ existingComment . id } ` ) ;
7190 } else {
7291 await github . rest . issues . createComment ( {
7392 owner,
7493 repo,
7594 issue_number : prNumber ,
76- body,
95+ body
7796 } ) ;
78- console . log ( 'Created new CI results comment' ) ;
7997 }
80- } catch ( error ) {
81- console . error ( 'Failed to post comment:' , error ) ;
98+ } catch ( err ) {
99+ console . error ( err ) ;
82100 }
83101} ;
0 commit comments