@@ -122,32 +122,43 @@ export class Docker {
122122 cacheFoundPath = await imageCache . find ( ) ;
123123 if ( cacheFoundPath ) {
124124 core . info ( `Image found from cache in ${ cacheFoundPath } ` ) ;
125- await Exec . getExecOutput ( `docker` , [ 'load' , '-i' , cacheFoundPath ] ) . catch ( e => {
126- core . warning ( `Failed to load image from cache: ${ e } ` ) ;
125+ await Exec . getExecOutput ( `docker` , [ 'load' , '-i' , cacheFoundPath ] , {
126+ ignoreReturnCode : true
127+ } ) . then ( res => {
128+ if ( res . stderr . length > 0 && res . exitCode != 0 ) {
129+ core . warning ( `Failed to load image from cache: ${ res . stderr . match ( / ( .* ) \s * $ / ) ?. [ 0 ] ?. trim ( ) ?? 'unknown error' } ` ) ;
130+ }
127131 } ) ;
128132 }
129133 }
130134
131135 let pulled = true ;
132- await Exec . getExecOutput ( `docker` , [ 'pull' , image ] ) . catch ( e => {
136+ await Exec . getExecOutput ( `docker` , [ 'pull' , image ] , {
137+ ignoreReturnCode : true
138+ } ) . then ( res => {
133139 pulled = false ;
134- if ( cacheFoundPath ) {
135- core . warning ( `Failed to pull image, using one from cache: ${ e } ` ) ;
136- } else {
137- throw new Error ( e ) ;
140+ if ( res . stderr . length > 0 && res . exitCode != 0 ) {
141+ const err = res . stderr . match ( / ( .* ) \s * $ / ) ?. [ 0 ] ?. trim ( ) ?? 'unknown error' ;
142+ if ( cacheFoundPath ) {
143+ core . warning ( `Failed to pull image, using one from cache: ${ err } ` ) ;
144+ } else {
145+ throw new Error ( err ) ;
146+ }
138147 }
139148 } ) ;
140149
141150 if ( cache && pulled ) {
142151 const imageTarPath = path . join ( Context . tmpDir ( ) , `${ Util . hash ( image ) } .tar` ) ;
143- await Exec . getExecOutput ( `docker` , [ 'save' , '-o' , imageTarPath , image ] )
144- . then ( async ( ) => {
152+ await Exec . getExecOutput ( `docker` , [ 'save' , '-o' , imageTarPath , image ] , {
153+ ignoreReturnCode : true
154+ } ) . then ( async res => {
155+ if ( res . stderr . length > 0 && res . exitCode != 0 ) {
156+ core . warning ( `Failed to save image: ${ res . stderr . match ( / ( .* ) \s * $ / ) ?. [ 0 ] ?. trim ( ) ?? 'unknown error' } ` ) ;
157+ } else {
145158 const cachePath = await imageCache . save ( imageTarPath ) ;
146159 core . info ( `Image cached to ${ cachePath } ` ) ;
147- } )
148- . catch ( e => {
149- core . warning ( `Failed to save image: ${ e } ` ) ;
150- } ) ;
160+ }
161+ } ) ;
151162 }
152163 }
153164}
0 commit comments