Add option to disable cache

This commit is contained in:
Patrick Dawson 2024-07-01 22:36:02 +02:00
parent d83cb325fa
commit c74534918c
4 changed files with 35 additions and 13 deletions

View File

@ -66,6 +66,10 @@ inputs:
description: >-
True will also download the Godot Export Templates for each platform.
default: false
cache:
description: >-
True to cache downloads.
default: true
runs:
using: 'node20'
main: 'dist/index.js'

21
dist/index.js generated vendored
View File

@ -63,6 +63,7 @@ function run(platform) {
const godotSharpRelease = core.getBooleanInput('godot-sharp-release');
const checkoutDirectory = (_a = process.env['GITHUB_WORKSPACE']) !== null && _a !== void 0 ? _a : '';
const includeTemplates = core.getBooleanInput('include-templates');
const useCache = core.getBooleanInput('cache');
const userDir = os.homedir();
const downloadsDir = path_1.default.join(userDir, downloadsRelativePath);
const installationDir = path_1.default.join(userDir, pathRelative);
@ -134,7 +135,13 @@ function run(platform) {
? [godotInstallationPath, exportTemplatePath]
: [godotInstallationPath];
const cacheKey = includeTemplates ? godotUrl : `${godotUrl}-no-templates`;
const cached = yield cache.restoreCache(cachedPaths.slice(), cacheKey);
let cached = undefined;
if (useCache) {
cached = yield cache.restoreCache(cachedPaths.slice(), cacheKey);
}
else {
core.info(`⏭️ Not using cache`);
}
let executables;
if (!cached) {
// Download Godot
@ -183,11 +190,13 @@ function run(platform) {
core.info(`✅ Files shown`);
core.endGroup();
}
// Save extracted Godot contents to cache
core.startGroup(`💾 Saving extracted Godot download to cache...`);
yield cache.saveCache(cachedPaths, cacheKey);
core.info(`✅ Godot saved to cache`);
core.endGroup();
if (useCache) {
// Save extracted Godot contents to cache
core.startGroup(`💾 Saving extracted Godot download to cache...`);
yield cache.saveCache(cachedPaths, cacheKey);
core.info(`✅ Godot saved to cache`);
core.endGroup();
}
}
else {
core.info(`🎉 Previous Godot download found in cache!`);

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -26,6 +26,7 @@ async function run(platform: Platform): Promise<void> {
const godotSharpRelease = core.getBooleanInput('godot-sharp-release')
const checkoutDirectory = process.env['GITHUB_WORKSPACE'] ?? ''
const includeTemplates = core.getBooleanInput('include-templates')
const useCache = core.getBooleanInput('cache')
const userDir = os.homedir()
const downloadsDir = path.join(userDir, downloadsRelativePath)
@ -123,7 +124,13 @@ async function run(platform: Platform): Promise<void> {
? [godotInstallationPath, exportTemplatePath]
: [godotInstallationPath]
const cacheKey = includeTemplates ? godotUrl : `${godotUrl}-no-templates`
const cached = await cache.restoreCache(cachedPaths.slice(), cacheKey)
let cached = undefined
if (useCache) {
cached = await cache.restoreCache(cachedPaths.slice(), cacheKey)
} else {
core.info(`⏭️ Not using cache`)
}
let executables: string[]
if (!cached) {
@ -217,11 +224,13 @@ async function run(platform: Platform): Promise<void> {
core.endGroup()
}
// Save extracted Godot contents to cache
core.startGroup(`💾 Saving extracted Godot download to cache...`)
await cache.saveCache(cachedPaths, cacheKey)
core.info(`✅ Godot saved to cache`)
core.endGroup()
if (useCache) {
// Save extracted Godot contents to cache
core.startGroup(`💾 Saving extracted Godot download to cache...`)
await cache.saveCache(cachedPaths, cacheKey)
core.info(`✅ Godot saved to cache`)
core.endGroup()
}
} else {
core.info(`🎉 Previous Godot download found in cache!`)
core.endGroup()