mirror of
https://github.com/renovatebot/github-action.git
synced 2025-12-16 08:52:35 +00:00
chore(release): 38.1.0 [skip ci]
This commit is contained in:
parent
0007deec0b
commit
f9a5a67d42
2 changed files with 31 additions and 1 deletions
30
dist/index.js
vendored
30
dist/index.js
vendored
|
|
@ -4090,6 +4090,9 @@ class Input {
|
|||
const version = core.getInput('renovate-version');
|
||||
return !!version && version !== '' ? version : null;
|
||||
}
|
||||
mountDockerSocket() {
|
||||
return core.getInput('mount-docker-socket') === 'true';
|
||||
}
|
||||
/**
|
||||
* Convert to environment variables.
|
||||
*
|
||||
|
|
@ -4156,6 +4159,9 @@ class Renovate {
|
|||
const mountPath = path_1.default.join(this.configFileMountDir, baseName);
|
||||
dockerArguments.push(`--env ${configurationFile.key}=${mountPath}`, `--volume ${configurationFile.value}:${mountPath}`);
|
||||
}
|
||||
if (this.input.mountDockerSocket()) {
|
||||
dockerArguments.push('--volume /var/run/docker.sock:/var/run/docker.sock', `--group-add ${this.getDockerGroupId()}`);
|
||||
}
|
||||
dockerArguments.push('--volume /tmp:/tmp', '--rm', this.docker.image());
|
||||
const command = `docker run ${dockerArguments.join(' ')}`;
|
||||
const code = await (0, exec_1.exec)(command);
|
||||
|
|
@ -4163,6 +4169,29 @@ class Renovate {
|
|||
new Error(`'docker run' failed with exit code ${code}.`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Fetch the host docker group of the GitHub Action runner.
|
||||
*
|
||||
* The Renovate container needs access to this group in order to have the
|
||||
* required permissions on the Docker socket.
|
||||
*/
|
||||
getDockerGroupId() {
|
||||
const groupFile = '/etc/group';
|
||||
const groups = fs_1.default.readFileSync(groupFile, {
|
||||
encoding: 'utf-8',
|
||||
});
|
||||
/**
|
||||
* The group file has `groupname:group-password:GID:username-list` as
|
||||
* structure and we're interested in the `GID` (the group ID).
|
||||
*
|
||||
* Source: https://www.thegeekdiary.com/etcgroup-file-explained/
|
||||
*/
|
||||
const match = Renovate.dockerGroupRegex.exec(groups);
|
||||
if (match?.groups?.groupId === undefined) {
|
||||
throw new Error(`Could not find group docker in ${groupFile}`);
|
||||
}
|
||||
return match.groups.groupId;
|
||||
}
|
||||
validateArguments() {
|
||||
if (/\s/.test(this.input.token.value)) {
|
||||
throw new Error('Token MUST NOT contain whitespace');
|
||||
|
|
@ -4175,6 +4204,7 @@ class Renovate {
|
|||
}
|
||||
}
|
||||
}
|
||||
Renovate.dockerGroupRegex = /^docker:x:(?<groupId>[1-9][0-9]*):/m;
|
||||
exports["default"] = Renovate;
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue