From 5619ef4781449b8774693be0a37f01d38a024bde Mon Sep 17 00:00:00 2001 From: Paul Zinselmeyer Date: Sat, 25 May 2024 10:29:36 +0200 Subject: [PATCH] feat: skip installation of attic when installed (#21) --- src/index.ts | 10 +++++++--- src/stages/install.ts | 5 +++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index b40f47a..c98c33e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,12 +1,16 @@ -import { install } from "./stages/install"; +import { install, isInstalled } from "./stages/install"; import { configure } from "./stages/configure"; import { push } from "./stages/push"; -import { getState, saveState } from "@actions/core"; +import { getState, saveState, info } from "@actions/core"; const isPost = !!getState("isPost"); const main = async () => { - await install(); + if (await isInstalled()) { + info("Skipping attic installation because it is already installed"); + } else { + await install(); + } await configure(); }; diff --git a/src/stages/install.ts b/src/stages/install.ts index 3014b9b..2b180ac 100644 --- a/src/stages/install.ts +++ b/src/stages/install.ts @@ -33,3 +33,8 @@ export const install = async () => { core.endGroup(); }; + +export const isInstalled = async () => { + let return_code = await exec("attic", ["-V"]); + return return_code === 0; +};