-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
68 lines (61 loc) · 1.95 KB
/
index.js
File metadata and controls
68 lines (61 loc) · 1.95 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
56
57
58
59
60
61
62
63
64
65
66
67
68
const core = require('@actions/core');
const tc = require('@actions/tool-cache');
const { getDownloadObject, startDfs, wait, userLogin, podOpen, move } = require('./lib/utils');
async function setup() {
try {
// Get version of tool to be installed
const version = core.getInput('version');
const downloadURL = getDownloadObject(version);
const pathToTarball = await tc.downloadTool(downloadURL);
const pathToCLI = await tc.extractZip(pathToTarball);
core.addPath(pathToCLI);
const bee = process.env.BEE
const rpc = process.env.RPC
const stamp = process.env.STAMP
const username = process.env.USER_NAME
const password = process.env.PASSWORD
const pod = process.env.POD
let destination = process.env.ROOT || "/"
if (bee == null || bee === "") {
core.setFailed("Environment variable BEE is not set")
return
}
if (rpc == null || rpc === "") {
core.setFailed("Environment variable RPC is not set")
return
}
if (stamp == null || stamp === "") {
core.setFailed("Environment variable STAMP is not set")
return
}
if (username == null || username === "") {
core.setFailed("Environment variable USER_NAME is not set")
return
}
if (password == null || password === "") {
core.setFailed("Environment variable PASSWORD is not set")
return
}
if (pod == null || pod === "") {
core.setFailed("Environment variable POD is not set")
return
}
if (destination === "") {
destination = "/"
}
const dfsProcess = await startDfs(bee, rpc, stamp);
await wait();
await userLogin(username, password);
await podOpen(pod);
const sourcePath = core.getInput('path', {required: true});
await move(pod, sourcePath, destination);
dfsProcess.unref();
process.exit();
} catch (e) {
core.setFailed(e);
}
}
module.exports = setup
if (require.main === module) {
setup().then(r => console.log(r));
}