Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config-file: bail if it doesn't exist and correctly mount if it does #204

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ async function run(): Promise<void> {
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',
Expand All @@ -61,16 +63,17 @@ async function run(): Promise<void> {
'/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')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not use the yaml file supplied in the parameters?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind. I see that the config file is mapped to this name inside the container..

}

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,
Expand Down