move runtime-basedir default to context

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2025-08-06 21:35:02 +02:00
parent de8d0f39ec
commit d2d8fc9bf5
3 changed files with 23 additions and 11 deletions

View File

@@ -1,3 +1,5 @@
import os from 'os';
import path from 'path';
import * as core from '@actions/core';
import {parse} from 'csv-parse/sync';
@@ -11,7 +13,7 @@ export interface Inputs {
context: string;
setHost: boolean;
rootless: boolean;
runtimeBasedir?: string;
runtimeBasedir: string;
}
export function getInputs(): Inputs {
@@ -29,7 +31,7 @@ export function getInputs(): Inputs {
context: core.getInput('context'),
setHost: core.getBooleanInput('set-host'),
rootless: core.getBooleanInput('rootless'),
runtimeBasedir: core.getInput('runtime-basedir')
runtimeBasedir: core.getInput('runtime-basedir') || path.join(os.homedir(), `setup-docker-action`)
};
}

View File

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