forked from PipedreamHQ/pipedream
-
Notifications
You must be signed in to change notification settings - Fork 0
/
new-commit.js
39 lines (38 loc) · 1.17 KB
/
new-commit.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
const github = require("https://github.com/PipedreamHQ/pipedream/components/github/github.app.js");
//const github = require("./github.app.js");
module.exports = {
name: "New Commit",
description: "Triggers on new commits to a repo or branch",
version: "0.0.1",
props: {
github,
repoFullName: { propDefinition: [github, "repoFullName"] },
branch: {
propDefinition: [github, "branch", c => ({ repoFullName: c.repoFullName })],
description: "Branch to monitor for new commits. If no branch is selected, the repository’s default branch will be used (usually master).",
},
timer: {
type: "$.interface.timer",
default: {
intervalSeconds: 60 * 5,
},
},
},
dedupe: "last",
async run(event) {
const config = {
repoFullName: this.repoFullName,
sha: this.branch,
}
console.log(config)
const commits = await this.github.getCommits(config)
console.log(commits)
commits.reverse().forEach(commit => {
this.$emit(commit, {
summary: commit.commit.message,
id: commit.sha,
ts: commit.commit.author.date && +new Date(commit.commit.author.date),
})
})
},
};