@@ -2,6 +2,7 @@ import * as core from '@actions/core'
22import * as exec from '@actions/exec'
33import * as github from '@actions/github'
44import stripAnsi from 'strip-ansi'
5+ import fs from 'fs'
56
67function format ( output : string ) : string {
78 const ret = [ '**The container image has inefficient files.**' ]
@@ -51,21 +52,25 @@ async function run(): Promise<void> {
5152 await exec . exec ( 'docker' , [ 'pull' , diveImage ] )
5253
5354 const commandOptions = [
54- 'run' ,
5555 '-e' ,
5656 'CI=true' ,
5757 '-e' ,
5858 'DOCKER_API_VERSION=1.37' ,
5959 '--rm' ,
60- '--mount' ,
61- `type=bind,source=${ configFile } ,target=/.dive-ci` ,
6260 '-v' ,
63- '/var/run/docker.sock:/var/run/docker.sock' ,
64- diveImage ,
65- '--ci-config' ,
66- '/.dive-ci' ,
67- image
61+ '/var/run/docker.sock:/var/run/docker.sock'
6862 ]
63+
64+ if ( fs . existsSync ( configFile ) ) {
65+ commandOptions . push (
66+ '--mount' ,
67+ `type=bind,source=${ configFile } ,target=/.dive-ci` ,
68+ '--ci-config' ,
69+ '/.dive-ci'
70+ )
71+ }
72+
73+ const parameters = [ 'run' , ...commandOptions , diveImage , image ]
6974 let output = ''
7075 const execOptions = {
7176 ignoreReturnCode : true ,
@@ -78,7 +83,7 @@ async function run(): Promise<void> {
7883 }
7984 }
8085 }
81- const exitCode = await exec . exec ( 'docker' , commandOptions , execOptions )
86+ const exitCode = await exec . exec ( 'docker' , parameters , execOptions )
8287 if ( exitCode === 0 ) {
8388 // success
8489 return
0 commit comments