-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (30 loc) · 990 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
const core = require("@actions/core");
const {NarkdownClient} = require("@narkdown/client");
const {NotionParser} = require("@narkdown/notion-parser");
try {
const notionAPIKey = core.getInput("notion-api-key");
const databaseId = core.getInput("database-id");
const propertyOptions = {
date: {
timeZone: core.getInput("date-option-timezone"),
format: core.getInput("date-option-format"),
},
};
const sortOptions = [
{
timestamp: core.getInput("sort-option-timestamp"),
direction: core.getInput("sort-option-direction"),
},
];
(async () => {
const narkdown = new NarkdownClient({ auth: notionAPIKey });
const notionParser = new NotionParser({ propertyOptions });
const { results } = await narkdown.unlimited.databases.query({
database_id: databaseId,
sorts: sortOptions,
});
core.setOutput("rows", notionParser.database.getRows(results));
})();
} catch (error) {
core.setFailed(error.message);
}