1
1
import * as fs from 'fs' ;
2
+ import * as path from 'path' ;
2
3
import * as stateHelper from './state-helper' ;
3
4
import * as core from '@actions/core' ;
4
5
import * as actionsToolkit from '@docker/actions-toolkit' ;
@@ -8,6 +9,7 @@ import {Exec} from '@docker/actions-toolkit/lib/exec';
8
9
import { GitHub } from '@docker/actions-toolkit/lib/github' ;
9
10
import { Inputs as BuildxInputs } from '@docker/actions-toolkit/lib/buildx/inputs' ;
10
11
import { Toolkit } from '@docker/actions-toolkit/lib/toolkit' ;
12
+ import { ConfigFile } from '@docker/actions-toolkit/lib/types/docker' ;
11
13
12
14
import * as context from './context' ;
13
15
@@ -34,9 +36,16 @@ actionsToolkit.run(
34
36
}
35
37
} ) ;
36
38
37
- const dockerConfig = await Docker . configFile ( ) ;
38
- if ( dockerConfig && dockerConfig . proxies ) {
39
- await core . group ( `Proxy configuration found` , async ( ) => {
39
+ await core . group ( `Proxy configuration` , async ( ) => {
40
+ let dockerConfig : ConfigFile | undefined ;
41
+ let dockerConfigMalformed = false ;
42
+ try {
43
+ dockerConfig = await Docker . configFile ( ) ;
44
+ } catch ( e ) {
45
+ dockerConfigMalformed = true ;
46
+ core . warning ( `Unable to parse config file ${ path . join ( Docker . configDir , 'config.json' ) } : ${ e } ` ) ;
47
+ }
48
+ if ( dockerConfig && dockerConfig . proxies ) {
40
49
for ( const host in dockerConfig . proxies ) {
41
50
let prefix = '' ;
42
51
if ( dockerConfig . proxies . length > 1 ) {
@@ -47,8 +56,10 @@ actionsToolkit.run(
47
56
core . info ( `${ prefix } ${ key } : ${ dockerConfig . proxies [ host ] [ key ] } ` ) ;
48
57
}
49
58
}
50
- } ) ;
51
- }
59
+ } else if ( ! dockerConfigMalformed ) {
60
+ core . info ( 'No proxy configuration found' ) ;
61
+ }
62
+ } ) ;
52
63
53
64
if ( ! ( await toolkit . buildx . isAvailable ( ) ) ) {
54
65
core . setFailed ( `Docker buildx is required. See https://github.com/docker/setup-buildx-action to set up buildx.` ) ;
0 commit comments