@@ -68,10 +68,18 @@ export class GitHub {
68
68
return `${ github . context . repo . owner } /${ github . context . repo . repo } ` ;
69
69
}
70
70
71
- public static workflowRunURL ( setAttempts ?: boolean ) : string {
71
+ static get runId ( ) : number {
72
+ return process . env . GITHUB_RUN_ID ? + process . env . GITHUB_RUN_ID : github . context . runId ;
73
+ }
74
+
75
+ static get runAttempt ( ) : number {
72
76
// TODO: runAttempt is not yet part of github.context but will be in a
73
77
// future release of @actions /github package: https://github.com/actions/toolkit/commit/faa425440f86f9c16587a19dfb59491253a2c92a
74
- return `${ GitHub . serverURL } /${ GitHub . repository } /actions/runs/${ github . context . runId } ${ setAttempts ? `/attempts/${ process . env . GITHUB_RUN_ATTEMPT || 1 } ` : '' } ` ;
78
+ return process . env . GITHUB_RUN_ATTEMPT ? + process . env . GITHUB_RUN_ATTEMPT : 1 ;
79
+ }
80
+
81
+ public static workflowRunURL ( setAttempts ?: boolean ) : string {
82
+ return `${ GitHub . serverURL } /${ GitHub . repository } /actions/runs/${ GitHub . runId } ${ setAttempts ? `/attempts/${ GitHub . runAttempt } ` : '' } ` ;
75
83
}
76
84
77
85
static get actionsRuntimeToken ( ) : GitHubActionsRuntimeToken | undefined {
@@ -211,6 +219,14 @@ export class GitHub {
211
219
212
220
const refsSize = Object . keys ( opts . exportRes . refs ) . length ;
213
221
222
+ // we just need the last two parts of the URL as they are always relative
223
+ // to the workflow run URL otherwise URL could be broken if GitHub
224
+ // repository name is part of a secret value used in the workflow. e.g.:
225
+ // artifact: https://github.com/docker/actions-toolkit/actions/runs/9552208295/artifacts/1609622746
226
+ // workflow: https://github.com/docker/actions-toolkit/actions/runs/9552208295
227
+ // https://github.com/docker/actions-toolkit/issues/367
228
+ const artifactRelativeURL = `./${ GitHub . runId } /${ opts . uploadRes . url . split ( '/' ) . slice ( - 2 ) . join ( '/' ) } ` ;
229
+
214
230
// prettier-ignore
215
231
const sum = core . summary
216
232
. addHeading ( 'Docker Build summary' , 1 )
@@ -221,7 +237,7 @@ export class GitHub {
221
237
. addRaw ( addLink ( 'Learn more' , 'https://docs.docker.com/go/build-summary/' ) )
222
238
. addRaw ( '</p>' )
223
239
. addRaw ( `<p>` )
224
- . addRaw ( `:arrow_down: ${ addLink ( `<strong>${ opts . uploadRes . filename } </strong>` , opts . uploadRes . url ) } (${ Util . formatFileSize ( opts . uploadRes . size ) } )` )
240
+ . addRaw ( `:arrow_down: ${ addLink ( `<strong>${ Util . stringToUnicodeEntities ( opts . uploadRes . filename ) } </strong>` , artifactRelativeURL ) } (${ Util . formatFileSize ( opts . uploadRes . size ) } )` )
225
241
. addBreak ( )
226
242
. addRaw ( `This file includes <strong>${ refsSize } build record${ refsSize > 1 ? 's' : '' } </strong>.` )
227
243
. addRaw ( `</p>` )
@@ -248,7 +264,7 @@ export class GitHub {
248
264
// prettier-ignore
249
265
summaryTableData . push ( [
250
266
{ data : `<code>${ ref . substring ( 0 , 6 ) . toUpperCase ( ) } </code>` } ,
251
- { data : `<strong>${ summary . name } </strong>` } ,
267
+ { data : `<strong>${ Util . stringToUnicodeEntities ( summary . name ) } </strong>` } ,
252
268
{ data : `${ summary . status === 'completed' ? ':white_check_mark:' : summary . status === 'canceled' ? ':no_entry_sign:' : ':x:' } ${ summary . status } ` } ,
253
269
{ data : `${ summary . numCachedSteps > 0 ? Math . round ( ( summary . numCachedSteps / summary . numTotalSteps ) * 100 ) : 0 } %` } ,
254
270
{ data : summary . duration }
0 commit comments