-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.js
74 lines (54 loc) · 1.94 KB
/
index.js
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const core = require('@actions/core');
const exec = require('@actions/exec');
const tc = require('@actions/tool-cache');
const io = require('@actions/io');
const path = require('path');
async function run() {
try {
let version = core.getInput('version');
let useLiquid = core.getInput('use_liquid');
let useLn = core.getInput('use_ln');
let useArk = core.getInput('use_ark');
let repository = core.getInput('repository_url');
core.info(`Installing Nigiri ${version}`);
core.info(`Repository URL ${repository}`);
const name = "nigiri";
const downloadURL = !version || version === "latest" ?
`${repository}/releases/latest/download/nigiri-linux-amd64` :
`${repository}/releases/download/${version}/nigiri-linux-amd64`;
let cachedPath = tc.find(name, version)
if (!cachedPath) {
core.addPath(cachedPath)
core.info(`Fetching from ${downloadURL}`)
const downloadPath = await tc.downloadTool(downloadURL);
cachedPath = await tc.cacheFile(downloadPath, name, name, version);
core.addPath(cachedPath)
}
core.info(`🍣 Nigiri Bitcoin installed`);
const filePath = path.join(cachedPath, name);
core.info(`Setting binary permissions...`);
await exec.exec("chmod", ["+rwx", filePath]);
const dataDir = "/home/runner/.nigiri";
core.info(`Creating ~/.nigiri folder...`);
await io.mkdirP(dataDir);
core.info(`Check Nigiri version...`);
await exec.exec(filePath, ["version"]);
core.info(`Setting ~/.nigiri permissions...`);
await exec.exec("chmod", ["-R", "777", dataDir]);
core.info(`Running Nigiri...`);
let args = ["start", "--ci"];
if (useLiquid === "true") {
args.push("--liquid");
}
if (useLn === "true") {
args.push("--ln");
}
if (useArk === "true") {
args.push("--ark");
}
await exec.exec(filePath, args);
} catch (error) {
core.setFailed(error.message);
}
}
run();