@@ -269,10 +269,10 @@ async function updateGithubIssue(urlResults) {
269
269
270
270
try {
271
271
const lines = body . split ( / \r ? \n / ) ; // support both \n and \r\n newline types
272
- const firstContentLine = lines . findIndex ( line => line . startsWith ( `|` ) ) + 2 ;
272
+ const firstContentLine = lines . indexOf ( `<table>` ) + 2 ;
273
273
lines . splice ( 0 , firstContentLine ) ; // delete first lines which only hold general data
274
274
for ( const line of lines ) {
275
- const [ , url , lastResults ] = line . match ( / ^ \| ( . * ) < t d n o w r a p > ( .* ) < \/ t d > $ / ) ;
275
+ const [ , lastResults , url ] = line . match ( / < t r > < t d n o w r a p > ( .* ? ) < \/ t d > < t d > < a h r e f = " ( . * ? ) " / ) ;
276
276
277
277
linkData [ url ] = lastResults . split ( ` ` ) . map ( item => {
278
278
if ( item === `:heavy_check_mark:` ) {
@@ -358,34 +358,41 @@ async function updateGithubIssue(urlResults) {
358
358
return linkData ;
359
359
}
360
360
361
+ /**
362
+ * @param {LinkStatus } status The status to get the linked emoji for.
363
+ * @returns {string } An emoji, wrapped in a link to the failed job if applicable.
364
+ */
365
+ function getStatusEmojiLink ( status ) {
366
+ if ( ! status . failed ) {
367
+ return `:heavy_check_mark:` ;
368
+ }
369
+
370
+ const message = status . message . replaceAll ( `\n` , ` ` ) . replaceAll ( `"` , `"` ) ;
371
+ const emoji = getFailedEmoji ( status . message ) ;
372
+ return `<a href="${ status . jobUrl } " title="${ message } ">${ emoji } </a>` ;
373
+ }
374
+
361
375
/**
362
376
* @param {LinkData } linkData The new link data from which to create the issue body.
363
377
* @returns {string } The new issue body (in Markdown and HTML) from the given link data.
364
378
*/
365
379
function getBodyFromLinkData ( linkData ) {
366
380
const scriptName = import . meta. url . split ( `/` ) . slice ( - 2 ) . join ( `/` ) ;
381
+ const rows = Object . entries ( linkData ) . map ( ( [ url , statuses ] ) => {
382
+ const statusIcons = statuses . map ( status => getStatusEmojiLink ( status ) ) . join ( ` ` ) ;
383
+ const link = `<a href="${ url } " target="_blank">${ url } </a>` ;
384
+ return `<tr><td nowrap>${ statusIcons } </td><td>${ link } </td></tr>` ;
385
+ } ) ;
367
386
const lines = [
368
387
`*Auto-generated content by \`${ scriptName } \`.*` ,
369
388
`` ,
370
389
`**Last updated:** ${ new Date ( ) . toISOString ( ) } ` ,
371
390
`` ,
372
- `| URL <th nowrap>today … 6 days ago</th>` ,
373
- `|--------------------------------------|` ,
374
- ...Object . entries ( linkData ) . map ( ( [ url , statuses ] ) => {
375
- const statusIcons = statuses . map ( status => {
376
- if ( ! status . failed ) {
377
- return `:heavy_check_mark:` ;
378
- }
379
-
380
- const message = status . message . replaceAll ( `\n` , ` ` ) . replaceAll ( `"` , `"` ) ;
381
- const emoji = getFailedEmoji ( status . message ) ;
382
- return `<a href="${ status . jobUrl } " title="${ message } ">${ emoji } </a>` ;
383
- } ) . join ( ` ` ) ;
384
-
385
- return `| ${ url } <td nowrap>${ statusIcons } </td>` ;
386
- } ) ,
391
+ `<table>` ,
392
+ `<tr><th nowrap>today … 6 days ago</th><th>URL</th></tr>` ,
393
+ ...rows ,
394
+ `</table>` ,
387
395
] ;
388
-
389
396
return lines . join ( `\n` ) ;
390
397
}
391
398
0 commit comments