forked from marlisumarli/sync-github-to-notion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (32 loc) · 1.09 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
import Core from "@actions/core";
import Github from "@actions/github";
import {NotionApi} from "./app/notion-api.js";
async function main() {
try {
const secret = Core.getInput('notion_secret');
const database = Core.getInput('notion_database');
const commits = Github.context.payload.commits;
commits.forEach((commit) => {
const array = commit.message.split(/\r?\n/);
const title = array.shift();
let description = "";
array.forEach((element) => {
description += element;
});
const notion = new NotionApi(secret, database);
notion.addItem({
commitTitle: title,
commitDescription: description,
commitBy: commit.author.name,
branch: Core.getInput('branch'),
commitUrl: commit.url,
project: Github.context.repo.repo,
commitId: commit.id
});
});
Core.info('Success');
} catch (error) {
Core.setFailed(error);
}
}
main();