Skip to content

Commit

Permalink
Merge pull request #6 from yuichielectric/check-if-config-file-exists
Browse files Browse the repository at this point in the history
Check if config file exists
  • Loading branch information
yuichielectric authored Sep 28, 2020
2 parents a359341 + 4043f22 commit c2bf577
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
16 changes: 7 additions & 9 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

23 changes: 14 additions & 9 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as core from '@actions/core'
import * as exec from '@actions/exec'
import * as github from '@actions/github'
import stripAnsi from 'strip-ansi'
import fs from 'fs'

function format(output: string): string {
const ret = ['**The container image has inefficient files.**']
Expand Down Expand Up @@ -51,21 +52,25 @@ async function run(): Promise<void> {
await exec.exec('docker', ['pull', diveImage])

const commandOptions = [
'run',
'-e',
'CI=true',
'-e',
'DOCKER_API_VERSION=1.37',
'--rm',
'--mount',
`type=bind,source=${configFile},target=/.dive-ci`,
'-v',
'/var/run/docker.sock:/var/run/docker.sock',
diveImage,
'--ci-config',
'/.dive-ci',
image
'/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 parameters = ['run', ...commandOptions, diveImage, image]
let output = ''
const execOptions = {
ignoreReturnCode: true,
Expand All @@ -78,7 +83,7 @@ async function run(): Promise<void> {
}
}
}
const exitCode = await exec.exec('docker', commandOptions, execOptions)
const exitCode = await exec.exec('docker', parameters, execOptions)
if (exitCode === 0) {
// success
return
Expand Down

0 comments on commit c2bf577

Please sign in to comment.