File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,6 +79,25 @@ export async function getInputs(): Promise<Inputs> {
7979 } ;
8080}
8181
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+
82101export async function getArgs ( inputs : Inputs , toolkit : Toolkit ) : Promise < Array < string > > {
83102 const context = handlebars . compile ( inputs . context ) ( {
84103 defaultContext : Context . gitContext ( )
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ actionsToolkit.run(
2323 const startedTime = new Date ( ) ;
2424 const inputs : context . Inputs = await context . getInputs ( ) ;
2525 core . debug ( `inputs: ${ JSON . stringify ( inputs ) } ` ) ;
26+ stateHelper . setInputs ( inputs ) ;
2627
2728 const toolkit = new Toolkit ( ) ;
2829
@@ -139,18 +140,23 @@ actionsToolkit.run(
139140 // post
140141 async ( ) => {
141142 if ( stateHelper . buildRef . length > 0 ) {
142- await core . group ( `Exporting build record ` , async ( ) => {
143+ await core . group ( `Generating build summary ` , async ( ) => {
143144 try {
144145 const buildxHistory = new BuildxHistory ( ) ;
145146 const exportRes = await buildxHistory . export ( {
146147 refs : [ stateHelper . buildRef ]
147148 } ) ;
148149 core . info ( `Build record exported to ${ exportRes . dockerbuildFilename } (${ Util . formatFileSize ( exportRes . dockerbuildSize ) } )` ) ;
149- await GitHub . uploadArtifact ( {
150+ const uploadRes = await GitHub . uploadArtifact ( {
150151 filename : exportRes . dockerbuildFilename ,
151152 mimeType : 'application/gzip' ,
152153 retentionDays : 90
153154 } ) ;
155+ await GitHub . writeBuildSummary ( {
156+ exportRes : exportRes ,
157+ uploadRes : uploadRes ,
158+ inputs : stateHelper . inputs
159+ } ) ;
154160 } catch ( e ) {
155161 core . warning ( e . message ) ;
156162 }
Original file line number Diff line number Diff line change 11import * as core from '@actions/core' ;
22
3+ import { Inputs , sanitizeInputs } from './context' ;
4+
35export const tmpDir = process . env [ 'STATE_tmpDir' ] || '' ;
6+ export const inputs = process . env [ 'STATE_inputs' ] ? JSON . parse ( process . env [ 'STATE_inputs' ] ) : undefined ;
47export const buildRef = process . env [ 'STATE_buildRef' ] || '' ;
58
69export function setTmpDir ( tmpDir : string ) {
710 core . saveState ( 'tmpDir' , tmpDir ) ;
811}
912
13+ export function setInputs ( inputs : Inputs ) {
14+ core . saveState ( 'inputs' , JSON . stringify ( sanitizeInputs ( inputs ) ) ) ;
15+ }
16+
1017export function setBuildRef ( buildRef : string ) {
1118 core . saveState ( 'buildRef' , buildRef ) ;
1219}
You can’t perform that action at this time.
0 commit comments