diff --git a/example/renovate.json b/example/renovate.json index 6f754950..c6adad3c 100644 --- a/example/renovate.json +++ b/example/renovate.json @@ -1,6 +1,6 @@ { "branchPrefix": "test-renovate/", - "dryRun": true, + "dryRun": "full", "username": "renovate-release", "gitAuthor": "Renovate Bot ", "onboarding": false, diff --git a/src/docker.ts b/src/docker.ts index adb6bb78..5a812ecb 100644 --- a/src/docker.ts +++ b/src/docker.ts @@ -1,7 +1,7 @@ import type { Input } from './input'; // renovate: datasource=docker depName=renovate/renovate versioning=docker -const tag = '34.159.2-slim'; +const tag = '35.0.0-slim'; class Docker { private static readonly repository = 'renovate/renovate'; diff --git a/src/renovate.ts b/src/renovate.ts index 8bf7a22b..aed10203 100644 --- a/src/renovate.ts +++ b/src/renovate.ts @@ -2,10 +2,10 @@ import Docker from './docker'; import { Input } from './input'; import { exec } from '@actions/exec'; import fs from 'fs'; +import os from 'os'; import path from 'path'; class Renovate { - private dockerGroupName = 'docker'; private configFileMountDir = '/github-action'; private docker: Docker; @@ -17,8 +17,6 @@ class Renovate { } async runDockerContainer(): Promise { - const renovateDockerUser = '1000'; - const dockerArguments = this.input .toEnvironmentVariables() .map((e) => `--env ${e.key}`) @@ -33,10 +31,11 @@ class Renovate { ); } + const user = os.userInfo(); + dockerArguments.push( - '--volume /var/run/docker.sock:/var/run/docker.sock', '--volume /tmp:/tmp', - `--user ${renovateDockerUser}:${this.getDockerGroupId()}`, + `--user ${user.uid}:0`, '--rm', this.docker.image() ); @@ -49,35 +48,6 @@ class Renovate { } } - /** - * 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. - */ - private getDockerGroupId(): string { - const groupFile = '/etc/group'; - const groups = fs.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 re = new RegExp(`^${this.dockerGroupName}:x:([1-9][0-9]*):`, 'm'); - const match = re.exec(groups); - if (!match || match.length < 2) { - throw new Error( - `Could not find group '${this.dockerGroupName}' in ${groupFile}` - ); - } - - return match[1]; - } - private validateArguments(): void { if (/\s/.test(this.input.token.value)) { throw new Error('Token MUST NOT contain whitespace');