-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
35 lines (29 loc) · 1004 Bytes
/
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
const core = require("@actions/core");
const github = require("@actions/github");
const fs = require("fs");
const neo4j = require("neo4j-driver");
const NEO4J_URI = core.getInput("neo4j-uri");
const NEO4J_USER = core.getInput("neo4j-user");
const NEO4J_PASSWORD = core.getInput("neo4j-password");
const FILENAME = core.getInput("filename");
const CYPHER_QUERY = core.getInput("cypher-query");
const driver = neo4j.driver(
NEO4J_URI,
neo4j.auth.basic(NEO4J_USER, NEO4J_PASSWORD)
);
const loadData = async () => {
const session = driver.session({ defaultAccessMode: neo4j.session.WRITE });
try {
const jsonData = JSON.parse(fs.readFileSync(FILENAME));
const tx = session.beginTransaction();
const result = await tx.run(CYPHER_QUERY, { value: jsonData });
result.records.forEach((record) => console.log(record));
await tx.commit();
} catch (error) {
core.setFailed(error.message);
} finally {
await session.close();
await driver.close();
}
};
loadData();