forked from aquiladev/ipfs-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runner.js
72 lines (66 loc) · 2.18 KB
/
runner.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
const core = require("@actions/core");
const github = require("@actions/github");
const uploader = require("./uploader");
async function run() {
try {
const path = core.getInput("path");
const pin = core.getInput("pin");
const pinName = core.getInput("pinName");
const service = core.getInput("service");
const host = core.getInput("host");
const port = core.getInput("port");
const protocol = core.getInput("protocol");
const headers = core.getInput("headers");
const key = core.getInput("key");
const pinataKey = core.getInput("pinataKey");
const pinataSecret = core.getInput("pinataSecret");
const pinataPinName = core.getInput("pinataPinName");
const filebaseBucket = core.getInput("filebaseBucket")
const filebaseKey = core.getInput("filebaseKey")
const filebaseSecret = core.getInput("filebaseSecret")
const infuraProjectId = core.getInput("infuraProjectId");
const infuraProjectSecret = core.getInput("infuraProjectSecret");
const nftStorageApiKey = core.getInput("nftStorageApiKey");
const timeout = core.getInput("timeout");
const verbose = core.getInput("verbose") === "true";
const options = {
path,
pin,
pinName,
service,
host,
port,
protocol,
headers: JSON.parse(headers || "{}"),
key,
pinataKey,
pinataSecret,
pinataPinName,
filebaseBucket,
filebaseKey,
filebaseSecret,
infuraProjectId,
infuraProjectSecret,
nftStorageApiKey,
timeout,
verbose,
};
const result = await uploader.upload(options).catch((err) => {
throw err;
});
core.setOutput("hash", result.ipfs);
core.setOutput("cid", result.cid);
core.setOutput("ipfs", result.ipfs);
core.setOutput("ipns", result.ipns);
if (verbose) {
// Get the JSON webhook payload for the event that triggered the workflow
const payload = JSON.stringify(github.context.payload, undefined, 2);
console.log(`The event payload: ${payload}`);
}
console.log("Upload to IPFS finished successfully", result);
} catch (error) {
core.setFailed(error.message);
throw error;
}
}
module.exports = run;