Move the started state to a statevar not an env var

This commit is contained in:
Graham Christensen 2024-05-07 09:37:28 -04:00
parent 0296fdb481
commit cddf736ff4

View file

@ -11,8 +11,7 @@ import * as path from "node:path";
import { inspect, promisify } from "node:util"; import { inspect, promisify } from "node:util";
const ENV_CACHE_DAEMONDIR = "MAGIC_NIX_CACHE_DAEMONDIR"; const ENV_CACHE_DAEMONDIR = "MAGIC_NIX_CACHE_DAEMONDIR";
const ENV_CACHE_STARTED = "MAGIC_NIX_CACHE_STARTED"; const STATE_STARTED = "MAGIC_NIX_CACHE_STARTED";
const STARTED_HINT = "true"; const STARTED_HINT = "true";
class MagicNixCacheAction { class MagicNixCacheAction {
@ -46,7 +45,7 @@ class MagicNixCacheAction {
}, },
}); });
this.daemonStarted = process.env[ENV_CACHE_STARTED] === STARTED_HINT; this.daemonStarted = actionsCore.getState(STATE_STARTED) === STARTED_HINT;
if (process.env[ENV_CACHE_DAEMONDIR]) { if (process.env[ENV_CACHE_DAEMONDIR]) {
this.daemonDir = process.env[ENV_CACHE_DAEMONDIR]; this.daemonDir = process.env[ENV_CACHE_DAEMONDIR];
@ -88,7 +87,7 @@ class MagicNixCacheAction {
); );
this.daemonStarted = true; this.daemonStarted = true;
actionsCore.exportVariable(ENV_CACHE_STARTED, STARTED_HINT); actionsCore.saveState(STATE_STARTED, STARTED_HINT);
const sourceBinary = inputs.getStringOrNull("source-binary"); const sourceBinary = inputs.getStringOrNull("source-binary");
const daemonBin = const daemonBin =
sourceBinary !== null ? sourceBinary : await this.fetchAutoCacher(); sourceBinary !== null ? sourceBinary : await this.fetchAutoCacher();