From ce977ffab46787bec5fbcc2e1303ee9fe91bfc70 Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Fri, 15 Sep 2023 00:12:36 +0800 Subject: [PATCH] fix: various fixes --- src/stages/configure.ts | 4 ++-- src/stages/push.ts | 3 +++ src/utils.ts | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/stages/configure.ts b/src/stages/configure.ts index a03eb34..b427bf6 100644 --- a/src/stages/configure.ts +++ b/src/stages/configure.ts @@ -15,10 +15,10 @@ export const configure = async () => { await exec("attic", ["login", "--set-default", cache, endpoint, token]); if (skipUse === "true") { - core.info('Not adding attic cache to substituters as skip-use is set to true'); + core.info("Not adding attic cache to substituters as skip-use is set to true"); } else { core.info("Adding attic cache to substituters"); - await exec.exec('attic', ['use', cache]); + await exec("attic", ["use", cache]); } core.info("Collecting store paths before build"); diff --git a/src/stages/push.ts b/src/stages/push.ts index e4ac8d4..0849ca8 100644 --- a/src/stages/push.ts +++ b/src/stages/push.ts @@ -3,17 +3,20 @@ import { exec } from "@actions/exec"; import splitArray from "just-split"; import { saveStorePaths, getStorePaths } from "../utils"; + export const push = async () => { core.startGroup("Push to Attic"); try { const skipPush = core.getInput("skip-push"); + if (skipPush === "true") { core.info("Pushing to cache is disabled by skip-push"); } else { const cache = core.getInput("cache"); core.info("Pushing to cache"); + const oldPaths = await getStorePaths(); await saveStorePaths(); const newPaths = await getStorePaths(); diff --git a/src/utils.ts b/src/utils.ts index d5632ba..f0218b9 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -3,8 +3,8 @@ import { exec } from "@actions/exec"; import { readFile } from "node:fs/promises"; export const saveStorePaths = async () => { - await exec("sh", ["-c", "nix path-info --all --json > /tmp/store-paths"]); + await exec("sh", ["-c", "nix path-info --all --json > /tmp/store-paths"]); }; export const getStorePaths = async () => { - return JSON.parse(await readFile("/tmp/store-paths", "utf8")).map((path) => path.path); + return (JSON.parse(await readFile("/tmp/store-paths", "utf8")) as { path: string }[]).map((path) => path.path); };