docker apply env on commands where we are using '-e' (#11)
* added wrapper for docker -e to apply env * added envs around services as well * added wrapping environment around execute command * fixed setting the env variable for containerRun * added env to exec and not to handle envs by ourself * returned back the comment to run-container-step
This commit is contained in:
@@ -69,7 +69,9 @@ export async function createContainer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const id = (await runDockerCommand(dockerArgs)).trim()
|
const id = (
|
||||||
|
await runDockerCommand(dockerArgs, { env: args.environmentVariables })
|
||||||
|
).trim()
|
||||||
if (!id) {
|
if (!id) {
|
||||||
throw new Error('Could not read id from docker command')
|
throw new Error('Could not read id from docker command')
|
||||||
}
|
}
|
||||||
@@ -352,7 +354,7 @@ export async function containerExecStep(
|
|||||||
for (const entryPointArg of args.entryPointArgs) {
|
for (const entryPointArg of args.entryPointArgs) {
|
||||||
dockerArgs.push(entryPointArg)
|
dockerArgs.push(entryPointArg)
|
||||||
}
|
}
|
||||||
await runDockerCommand(dockerArgs)
|
await runDockerCommand(dockerArgs, { env: args.environmentVariables })
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function containerRun(
|
export async function containerRun(
|
||||||
@@ -376,9 +378,7 @@ export async function containerRun(
|
|||||||
dockerArgs.push(...args.createOptions.split(' '))
|
dockerArgs.push(...args.createOptions.split(' '))
|
||||||
}
|
}
|
||||||
if (args.environmentVariables) {
|
if (args.environmentVariables) {
|
||||||
for (const [key, value] of Object.entries(args.environmentVariables)) {
|
for (const [key] of Object.entries(args.environmentVariables)) {
|
||||||
// Pass in this way to avoid printing secrets
|
|
||||||
env[key] = value ?? undefined
|
|
||||||
dockerArgs.push('-e')
|
dockerArgs.push('-e')
|
||||||
dockerArgs.push(key)
|
dockerArgs.push(key)
|
||||||
}
|
}
|
||||||
@@ -408,7 +408,7 @@ export async function containerRun(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await runDockerCommand(dockerArgs)
|
await runDockerCommand(dockerArgs, { env: args.environmentVariables })
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function isContainerAlpine(containerId: string): Promise<boolean> {
|
export async function isContainerAlpine(containerId: string): Promise<boolean> {
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ export async function prepareJob(
|
|||||||
} finally {
|
} finally {
|
||||||
await registryLogout(configLocation)
|
await registryLogout(configLocation)
|
||||||
}
|
}
|
||||||
|
|
||||||
containerMetadata = await createContainer(
|
containerMetadata = await createContainer(
|
||||||
container,
|
container,
|
||||||
generateContainerName(container.image),
|
generateContainerName(container.image),
|
||||||
@@ -78,6 +79,7 @@ export async function prepareJob(
|
|||||||
generateContainerName(service.image),
|
generateContainerName(service.image),
|
||||||
networkName
|
networkName
|
||||||
)
|
)
|
||||||
|
|
||||||
servicesMetadata.push(response)
|
servicesMetadata.push(response)
|
||||||
await containerStart(response.id)
|
await containerStart(response.id)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ const exec = require('@actions/exec')
|
|||||||
export interface RunDockerCommandOptions {
|
export interface RunDockerCommandOptions {
|
||||||
workingDir?: string
|
workingDir?: string
|
||||||
input?: Buffer
|
input?: Buffer
|
||||||
|
env?: { [key: string]: string }
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function runDockerCommand(
|
export async function runDockerCommand(
|
||||||
|
|||||||
Reference in New Issue
Block a user