feat: allow to override docker command and user (#783)

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
This commit is contained in:
Cédric Cabessa 2023-10-16 11:16:31 +02:00 committed by GitHub
parent 577b35899d
commit 8d4ffe3283
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 102 additions and 0 deletions

View file

@ -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.
*

View file

@ -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);