add runtime-basedir input

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
ArunKumarT1995 2025-08-06 18:48:28 +05:30 committed by CrazyMax
parent 29412e2cf6
commit de8d0f39ec
No known key found for this signature in database
GPG Key ID: ADE44D8C9D44FBE4
4 changed files with 10 additions and 4 deletions

View File

@ -121,8 +121,8 @@ The following inputs can be used as `step.with` keys
| `tcp-port` | Number | | TCP port to expose the Docker API locally | | `tcp-port` | Number | | TCP port to expose the Docker API locally |
| `context` | String | `setup-docker-action` | Docker context name. | | `context` | String | `setup-docker-action` | Docker context name. |
| `set-host` | Bool | `false` | Set `DOCKER_HOST` environment variable to docker socket path. | | `set-host` | Bool | `false` | Set `DOCKER_HOST` environment variable to docker socket path. |
| `rootless` | Bool | `false` | Start daemon in rootless mode | | `rootless` | Bool | `false` | Start daemon in rootless mode |
| `runtime-basedir` | String | `<home>/setup-docker-action` | Docker runtime base directory
### inputs.version ### inputs.version
By default, the latest stable version of Docker is fetched from download.docker.com. By default, the latest stable version of Docker is fetched from download.docker.com.

View File

@ -31,6 +31,9 @@ inputs:
description: 'Enable Docker rootless mode' description: 'Enable Docker rootless mode'
default: 'false' default: 'false'
required: false required: false
runtime-basedir:
description: 'Docker runtime base directory'
required: false
outputs: outputs:
sock: sock:

View File

@ -11,6 +11,7 @@ export interface Inputs {
context: string; context: string;
setHost: boolean; setHost: boolean;
rootless: boolean; rootless: boolean;
runtimeBasedir?: string;
} }
export function getInputs(): Inputs { export function getInputs(): Inputs {
@ -27,7 +28,8 @@ export function getInputs(): Inputs {
tcpPort: Util.getInputNumber('tcp-port'), tcpPort: Util.getInputNumber('tcp-port'),
context: core.getInput('context'), context: core.getInput('context'),
setHost: core.getBooleanInput('set-host'), setHost: core.getBooleanInput('set-host'),
rootless: core.getBooleanInput('rootless') rootless: core.getBooleanInput('rootless'),
runtimeBasedir: core.getInput('runtime-basedir')
}; };
} }

View File

@ -18,7 +18,8 @@ actionsToolkit.run(
// main // main
async () => { async () => {
const input: context.Inputs = context.getInputs(); const input: context.Inputs = context.getInputs();
const runDir = path.join(os.homedir(), `setup-docker-action-${crypto.randomUUID().slice(0, 8)}`); const runBasedir = input.runtimeBasedir || path.join(os.homedir(), `setup-docker-action`);
const runDir = path.join(runBasedir, `run-${crypto.randomUUID().slice(0, 8)}`);
if (input.context == 'default') { if (input.context == 'default') {
throw new Error(`'default' context cannot be used.`); throw new Error(`'default' context cannot be used.`);