mirror of
https://github.com/renovatebot/github-action.git
synced 2025-12-16 08:52:35 +00:00
feat: allow to override docker command and user (#783)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
This commit is contained in:
parent
577b35899d
commit
8d4ffe3283
6 changed files with 102 additions and 0 deletions
|
|
@ -73,6 +73,15 @@ class Input {
|
|||
return core.getInput('mount-docker-socket') === 'true';
|
||||
}
|
||||
|
||||
getDockerCmdFile(): string | null {
|
||||
const cmdFile = core.getInput('docker-cmd-file');
|
||||
return !!cmdFile && cmdFile !== '' ? path.resolve(cmdFile) : null;
|
||||
}
|
||||
|
||||
getDockerUser(): string | null {
|
||||
return core.getInput('docker-user') || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to environment variables.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -39,8 +39,26 @@ class Renovate {
|
|||
);
|
||||
}
|
||||
|
||||
const dockerCmdFile = this.input.getDockerCmdFile();
|
||||
let dockerCmd: string | null = null;
|
||||
if (dockerCmdFile !== null) {
|
||||
const baseName = path.basename(dockerCmdFile);
|
||||
const mountPath = `/${baseName}`;
|
||||
dockerArguments.push(`--volume ${dockerCmdFile}:${mountPath}`);
|
||||
dockerCmd = mountPath;
|
||||
}
|
||||
|
||||
const dockerUser = this.input.getDockerUser();
|
||||
if (dockerUser !== null) {
|
||||
dockerArguments.push(`--user ${dockerUser}`);
|
||||
}
|
||||
|
||||
dockerArguments.push('--volume /tmp:/tmp', '--rm', this.docker.image());
|
||||
|
||||
if (dockerCmd !== null) {
|
||||
dockerArguments.push(dockerCmd);
|
||||
}
|
||||
|
||||
const command = `docker run ${dockerArguments.join(' ')}`;
|
||||
|
||||
const code = await exec(command);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue