Skip to content

Commit

Permalink
Respect RUNNER_TEMP environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
svdschoot-wefabricate committed Oct 27, 2023
1 parent 7b1a9e4 commit d324734
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d324734

Please sign in to comment.