Commit d880b19 1 parent e51051a commit d880b19 Copy full SHA for d880b19
File tree 3 files changed +34
-2
lines changed
3 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,25 @@ export async function getInputs(): Promise<Inputs> {
79
79
} ;
80
80
}
81
81
82
+ export function sanitizeInputs ( inputs : Inputs ) {
83
+ const res = { } ;
84
+ for ( const key of Object . keys ( inputs ) ) {
85
+ if ( key === 'github-token' ) {
86
+ continue ;
87
+ }
88
+ const value : string | string [ ] | boolean = inputs [ key ] ;
89
+ if ( typeof value === 'boolean' && value === false ) {
90
+ continue ;
91
+ } else if ( Array . isArray ( value ) && value . length === 0 ) {
92
+ continue ;
93
+ } else if ( ! value ) {
94
+ continue ;
95
+ }
96
+ res [ key ] = value ;
97
+ }
98
+ return res ;
99
+ }
100
+
82
101
export async function getArgs ( inputs : Inputs , toolkit : Toolkit ) : Promise < Array < string > > {
83
102
const context = handlebars . compile ( inputs . context ) ( {
84
103
defaultContext : Context . gitContext ( )
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ actionsToolkit.run(
23
23
const startedTime = new Date ( ) ;
24
24
const inputs : context . Inputs = await context . getInputs ( ) ;
25
25
core . debug ( `inputs: ${ JSON . stringify ( inputs ) } ` ) ;
26
+ stateHelper . setInputs ( inputs ) ;
26
27
27
28
const toolkit = new Toolkit ( ) ;
28
29
@@ -139,18 +140,23 @@ actionsToolkit.run(
139
140
// post
140
141
async ( ) => {
141
142
if ( stateHelper . buildRef . length > 0 ) {
142
- await core . group ( `Exporting build record ` , async ( ) => {
143
+ await core . group ( `Generating build summary ` , async ( ) => {
143
144
try {
144
145
const buildxHistory = new BuildxHistory ( ) ;
145
146
const exportRes = await buildxHistory . export ( {
146
147
refs : [ stateHelper . buildRef ]
147
148
} ) ;
148
149
core . info ( `Build record exported to ${ exportRes . dockerbuildFilename } (${ Util . formatFileSize ( exportRes . dockerbuildSize ) } )` ) ;
149
- await GitHub . uploadArtifact ( {
150
+ const uploadRes = await GitHub . uploadArtifact ( {
150
151
filename : exportRes . dockerbuildFilename ,
151
152
mimeType : 'application/gzip' ,
152
153
retentionDays : 90
153
154
} ) ;
155
+ await GitHub . writeBuildSummary ( {
156
+ exportRes : exportRes ,
157
+ uploadRes : uploadRes ,
158
+ inputs : stateHelper . inputs
159
+ } ) ;
154
160
} catch ( e ) {
155
161
core . warning ( e . message ) ;
156
162
}
Original file line number Diff line number Diff line change 1
1
import * as core from '@actions/core' ;
2
2
3
+ import { Inputs , sanitizeInputs } from './context' ;
4
+
3
5
export const tmpDir = process . env [ 'STATE_tmpDir' ] || '' ;
6
+ export const inputs = process . env [ 'STATE_inputs' ] ? JSON . parse ( process . env [ 'STATE_inputs' ] ) : undefined ;
4
7
export const buildRef = process . env [ 'STATE_buildRef' ] || '' ;
5
8
6
9
export function setTmpDir ( tmpDir : string ) {
7
10
core . saveState ( 'tmpDir' , tmpDir ) ;
8
11
}
9
12
13
+ export function setInputs ( inputs : Inputs ) {
14
+ core . saveState ( 'inputs' , JSON . stringify ( sanitizeInputs ( inputs ) ) ) ;
15
+ }
16
+
10
17
export function setBuildRef ( buildRef : string ) {
11
18
core . saveState ( 'buildRef' , buildRef ) ;
12
19
}
You can’t perform that action at this time.
0 commit comments