From d3247341f3ff95c82098a0f3243fb09266b0d162 Mon Sep 17 00:00:00 2001 From: Steven van der Schoot Date: Fri, 27 Oct 2023 10:15:33 +0200 Subject: [PATCH] Respect RUNNER_TEMP environment variable --- src/context.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/context.ts b/src/context.ts index ad50da6d..92cce2c5 100644 --- a/src/context.ts +++ b/src/context.ts @@ -23,7 +23,17 @@ import * as github from '@actions/github'; import {GitHub} from './github'; export class Context { - private static readonly _tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-actions-toolkit-')); + private static readonly _tmpDir = fs.mkdtempSync(path.join(Context._tryCreateDirctory(process.env.RUNNER_TEMP) || os.tmpdir(), 'docker-actions-toolkit-')); + + private static _tryCreateDirctory(directoryPath: string | undefined): string | undefined { + if (directoryPath !== undefined) { + const createdPath = fs.mkdirSync(directoryPath, {recursive: true}); + if (createdPath !== directoryPath) { + return undefined; + } + } + return directoryPath; + } public static tmpDir(): string { return Context._tmpDir;