diff --git a/sources/src/execution/provision.ts b/sources/src/execution/provision.ts index ae02b90..685ac23 100644 --- a/sources/src/execution/provision.ts +++ b/sources/src/execution/provision.ts @@ -100,7 +100,7 @@ async function installGradleVersion(versionInfo: GradleVersionInfo): Promise { - const installsDir = path.join(os.homedir(), 'gradle-installations/installs') + const installsDir = path.join(getProvisionDir(), 'installs') const installDir = path.join(installsDir, `gradle-${versionInfo.version}`) if (fs.existsSync(installDir)) { core.info(`Gradle installation already exists at ${installDir}`) @@ -119,7 +119,7 @@ async function locateGradleAndDownloadIfRequired(versionInfo: GradleVersionInfo) } async function downloadAndCacheGradleDistribution(versionInfo: GradleVersionInfo): Promise { - const downloadPath = path.join(os.homedir(), `gradle-installations/downloads/gradle-${versionInfo.version}-bin.zip`) + const downloadPath = path.join(getProvisionDir(), `downloads/gradle-${versionInfo.version}-bin.zip`) // TODO: Convert this to a class and inject config const cacheConfig = new CacheConfig() @@ -152,6 +152,11 @@ async function downloadAndCacheGradleDistribution(versionInfo: GradleVersionInfo return downloadPath } +function getProvisionDir(): string { + const tmpDir = process.env['RUNNER_TEMP'] ?? os.tmpdir() + return path.join(tmpDir, `.gradle-actions/gradle-installations`) +} + async function downloadGradleDistribution(versionInfo: GradleVersionInfo, downloadPath: string): Promise { await toolCache.downloadTool(versionInfo.downloadUrl, downloadPath) core.info(`Downloaded ${versionInfo.downloadUrl} to ${downloadPath} (size ${fs.statSync(downloadPath).size})`)