forked from DopplerHQ/cli-action
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
55 lines (48 loc) · 1.52 KB
/
index.js
File metadata and controls
55 lines (48 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const core = require("@actions/core");
const tc = require("@actions/tool-cache");
const io = require("@actions/io");
const { execSync } = require("child_process");
const workspace = process.env.GITHUB_WORKSPACE;
const binDir = `${workspace}/bin`;
run().catch((error) => {
core.setFailed(error.message);
});
async function run() {
switch (process.platform) {
case "win32": {
const url =
"https://cli.doppler.com/download?os=windows&arch=amd64&format=zip";
await installZip(binDir, url);
break;
}
case "linux":
case "darwin": {
await executeInstallSh(binDir);
break;
}
default: {
throw new Error(`Unsupported platform '${process.platform}'`);
}
}
}
async function installZip(path, url) {
await io.mkdirP(path);
const downloadPath = await tc.downloadTool(url);
await tc.extractZip(downloadPath, path);
core.addPath(path);
}
async function executeInstallSh(installPath) {
// download script
const url =
"https://github.com/DopplerHQ/cli/releases/download/3.75.0/doppler_3.75.0_linux_amd64.deb";
const downloadPath = await tc.downloadTool(url);
execSync(`chmod +x ${downloadPath}`);
execSync(`dpkg -i ${downloadPath}`);
// execute script
// await io.mkdirP(installPath);
// const installCommand = `${downloadPath} --debug --no-package-manager --install-path ${installPath}`;
// stdout = execSync(installCommand, { timeout: 30000 });
// console.log(Buffer.from(stdout).toString("utf-8"));
// add binary to PATH
core.addPath(installPath);
}