File tree 3 files changed +12
-9
lines changed
3 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,10 @@ describe('repository', () => {
97
97
98
98
describe ( 'workflowRunURL' , ( ) => {
99
99
it ( 'returns 2188748038' , async ( ) => {
100
- expect ( GitHub . workflowRunURL ) . toEqual ( 'https://github.com/docker/actions-toolkit/actions/runs/2188748038/attempts/2' ) ;
100
+ expect ( GitHub . workflowRunURL ( ) ) . toEqual ( 'https://github.com/docker/actions-toolkit/actions/runs/2188748038' ) ;
101
+ } ) ;
102
+ it ( 'returns 2188748038 with attempts 2' , async ( ) => {
103
+ expect ( GitHub . workflowRunURL ( true ) ) . toEqual ( 'https://github.com/docker/actions-toolkit/actions/runs/2188748038/attempts/2' ) ;
101
104
} ) ;
102
105
} ) ;
103
106
Original file line number Diff line number Diff line change @@ -131,7 +131,7 @@ export class Build {
131
131
return input ;
132
132
}
133
133
try {
134
- return core . getBooleanInput ( name ) ? `builder-id=${ GitHub . workflowRunURL } ` : 'false' ;
134
+ return core . getBooleanInput ( name ) ? `builder-id=${ GitHub . workflowRunURL ( true ) } ` : 'false' ;
135
135
} catch ( err ) {
136
136
// not a valid boolean, so we assume it's a string
137
137
return Build . resolveProvenanceAttrs ( input ) ;
@@ -140,7 +140,7 @@ export class Build {
140
140
141
141
public static resolveProvenanceAttrs ( input : string ) : string {
142
142
if ( ! input ) {
143
- return `builder-id=${ GitHub . workflowRunURL } ` ;
143
+ return `builder-id=${ GitHub . workflowRunURL ( true ) } ` ;
144
144
}
145
145
// parse attributes from input
146
146
const fields = parse ( input , {
@@ -158,7 +158,7 @@ export class Build {
158
158
}
159
159
}
160
160
// if not add builder-id attribute
161
- return `${ input } ,builder-id=${ GitHub . workflowRunURL } ` ;
161
+ return `${ input } ,builder-id=${ GitHub . workflowRunURL ( true ) } ` ;
162
162
}
163
163
164
164
public static resolveCacheToAttrs ( input : string , githubToken ?: string ) : string {
Original file line number Diff line number Diff line change @@ -68,10 +68,10 @@ export class GitHub {
68
68
return `${ github . context . repo . owner } /${ github . context . repo . repo } ` ;
69
69
}
70
70
71
- static get workflowRunURL ( ) : string {
72
- const runID = process . env . GITHUB_RUN_ID || github . context . runId ;
73
- const runAttempt = process . env . GITHUB_RUN_ATTEMPT || 1 ;
74
- return `${ GitHub . serverURL } /${ GitHub . repository } /actions/runs/${ runID } /attempts/${ runAttempt } ` ;
71
+ public static workflowRunURL ( setAttempts ?: boolean ) : string {
72
+ // TODO: runAttempt is not yet part of github.context but will be in a
73
+ // 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 } ` : '' } ` ;
75
75
}
76
76
77
77
static get actionsRuntimeToken ( ) : GitHubActionsRuntimeToken | undefined {
@@ -191,7 +191,7 @@ export class GitHub {
191
191
const artifactId = BigInt ( finalizeArtifactResp . artifactId ) ;
192
192
core . info ( `Artifact successfully finalized (${ artifactId } )` ) ;
193
193
194
- const artifactURL = `${ GitHub . workflowRunURL } /artifacts/${ artifactId } ` ;
194
+ const artifactURL = `${ GitHub . workflowRunURL ( ) } /artifacts/${ artifactId } ` ;
195
195
core . info ( `Artifact download URL: ${ artifactURL } ` ) ;
196
196
197
197
return {
You can’t perform that action at this time.
0 commit comments