Use install function from install-cli-action

This commit is contained in:
Volodymyr Zotov
2025-07-25 13:11:13 -05:00
parent 43fd9cdb84
commit 37a38cf129
4 changed files with 36144 additions and 3769 deletions

39370
dist/index.js vendored

File diff suppressed because one or more lines are too long

522
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -39,6 +39,7 @@
}, },
"homepage": "https://github.com/1Password/load-secrets-action#readme", "homepage": "https://github.com/1Password/load-secrets-action#readme",
"dependencies": { "dependencies": {
"@1password/install-cli-action": "github:1password/install-cli-action#vzt/export-install-function",
"@1password/op-js": "^0.1.11", "@1password/op-js": "^0.1.11",
"@actions/core": "^1.10.1", "@actions/core": "^1.10.1",
"@actions/exec": "^1.1.1" "@actions/exec": "^1.1.1"

View File

@@ -1,8 +1,6 @@
import path from "path";
import url from "url";
import * as core from "@actions/core"; import * as core from "@actions/core";
import * as exec from "@actions/exec";
import { validateCli } from "@1password/op-js"; import { validateCli } from "@1password/op-js";
import { install } from "@1password/install-cli-action/dist";
import { loadSecrets, unsetPrevious, validateAuth } from "./utils"; import { loadSecrets, unsetPrevious, validateAuth } from "./utils";
const loadSecretsAction = async () => { const loadSecretsAction = async () => {
@@ -46,21 +44,7 @@ const installCLI = async (): Promise<void> => {
// If there's no CLI installed, then validateCli will throw an error, which we will use // If there's no CLI installed, then validateCli will throw an error, which we will use
// as an indicator that we need to execute the installation script. // as an indicator that we need to execute the installation script.
await validateCli().catch(async () => { await validateCli().catch(async () => {
const currentFile = url.fileURLToPath(import.meta.url); await install()
const currentDir = path.dirname(currentFile);
const parentDir = path.resolve(currentDir, "..");
// Execute bash script
const cmdOut = await exec.getExecOutput(
`sh -c "` + parentDir + `/install_cli.sh"`,
);
// Add path to 1Password CLI to $PATH
const outArr = cmdOut.stdout.split("\n");
if (outArr[0] && process.env.PATH) {
const cliPath = outArr[0]?.replace(/^(::debug::OP_INSTALL_DIR: )/, "");
core.addPath(cliPath);
}
}); });
}; };