This repository has been archived by the owner on Apr 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
44 lines (38 loc) · 1.64 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
37
38
39
40
41
42
43
44
/**
* This is the entry point for your Probot App.
* @param {import('probot').Application} app - Probot's Application class.
*/
module.exports = app => {
// Your code here
app.log('Yay, the app was loaded!')
app.on('issues.opened', async context => {
app.log('open')
const issueComment = context.issue({ body: 'issue open TEST' })
return context.github.issues.createComment(issueComment)
})
app.on('issues.edited', async context => {
app.log('edited');
const issueComment = context.issue({ body: 'issue edited TEST' })
return context.github.issues.createComment(issueComment)
})
app.on('pull_request.opened', async context => {
const filesChanged = await context.github.pullRequests.getFiles(context.issue())
console.log("filesChanged", filesChanged)
const results = filesChanged.data.filter(file => file.filename.includes('.md'))
console.log("results", `${context.payload.pull_request.head.repo.html_url}/blob/${context.payload.pull_request.head.ref}`)
if (results && results.length > 0) {
// make URLs
let urls = ''
await results.forEach(async (result) => {
urls += `[${result.filename}](${context.payload.pull_request.head.repo.html_url}/blob/${context.payload.pull_request.head.ref}/${result.filename})`
})
await context.github.pullRequests.update(context.issue({body: `${context.payload.pull_request.body}\n${urls}`}))
}
})
// app.on('pull_request.edited', async context => {
// })
// For more information on building apps:
// https://probot.github.io/docs/
// To get your app running against GitHub, see:
// https://probot.github.io/docs/development/
}