From c4fc3636a0bc38cdc9a8ddcd2665affa59a6e732 Mon Sep 17 00:00:00 2001 From: Nathan Date: Mon, 7 Jun 2021 12:07:35 -0700 Subject: [PATCH] config-file: bail if it doesn't exist and correctly mount if it does --- src/main.ts | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/main.ts b/src/main.ts index 8cf92cd4..3510766e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -48,10 +48,12 @@ async function run(): Promise { const image = core.getInput('image') const configFile = core.getInput('config-file') - const diveImage = 'wagoodman/dive:v0.9' - await exec.exec('docker', ['pull', diveImage]) - - const commandOptions = [ + if (configFile && !fs.existsSync(configFile)) { + core.setFailed(`Dive configuration file ${configFile} doesn't exist!`) + return + } + + const runOptions = [ '-e', 'CI=true', '-e', @@ -61,16 +63,17 @@ async function run(): Promise { '/var/run/docker.sock:/var/run/docker.sock' ] - if (fs.existsSync(configFile)) { - commandOptions.push( - '--mount', - `type=bind,source=${configFile},target=/.dive-ci`, - '--ci-config', - '/.dive-ci' - ) + const cmdOptions = [] + + if (configFile) { + runOptions.push('-v', `${configFile}:/.dive-ci`) + cmdOptions.push('--config-file', '/.dive-ci') } - - const parameters = ['run', ...commandOptions, diveImage, image] + + const diveImage = 'wagoodman/dive:v0.9' + await exec.exec('docker', ['pull', diveImage]) + + const parameters = ['run', ...runOptions, diveImage, image, ...cmdOptions] let output = '' const execOptions = { ignoreReturnCode: true,