Skip to content

Commit

Permalink
feat: add "ping" event
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Dec 11, 2018
1 parent a7b59fa commit 8804b73
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
30 changes: 30 additions & 0 deletions index.json
Original file line number Diff line number Diff line change
Expand Up @@ -6288,5 +6288,35 @@
}
}
]
},
{
"name": "ping",
"actions": [],
"example": [
{
"event": "ping",
"payload": {
"zen": "Design for failure.",
"hook_id": 123,
"hook": {
"type": "App",
"id": 123,
"name": "web",
"active": true,
"events": [
"pull_request"
],
"config": {
"content_type": "json",
"insecure_ssl": "0",
"url": "https://my-app.com/webhook"
},
"updated_at": "2018-12-11T21:18:31Z",
"created_at": "2018-12-11T21:18:31Z",
"app_id": 456
}
}
}
]
}
]
3 changes: 3 additions & 0 deletions lib/check-or-update-webhooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { diff, diffString } = require('json-diff')

const createPrOnChange = require('./create-pr-on-change')
const getHtml = require('./get-html')
const getPingWebhook = require('./get-ping-webhook')
const getSections = require('./get-sections')
const toWebhook = require('./section-to-webhook')

Expand All @@ -18,6 +19,8 @@ async function checkOrUpdateWebhooks ({ cached, checkOnly }) {
const sections = await getSections(state, html)
const wekhooks = sections.map(toWebhook.bind(null, state)).filter(Boolean)

wekhooks.push(getPingWebhook())

const currentWebhooks = require('../index.json')

if (!diff(currentWebhooks, wekhooks)) {
Expand Down
34 changes: 34 additions & 0 deletions lib/get-ping-webhook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = getPingWebhook

/**
* The "ping" webhook is currently not listed on https://developer.github.com/v3/activity/events/types
* @see https://github.com/octokit/webhooks/issues/3
*/
function getPingWebhook () {
return {
name: 'ping',
actions: [],
example: [{
event: 'ping',
payload: {
zen: 'Design for failure.',
hook_id: 123,
hook: {
type: 'App',
id: 123,
name: 'web',
active: true,
events: ['pull_request'],
config: {
content_type: 'json',
insecure_ssl: '0',
url: 'https://my-app.com/webhook'
},
updated_at: '2018-12-11T21:18:31Z',
created_at: '2018-12-11T21:18:31Z',
app_id: 456
}
}
}]
}
}

0 comments on commit 8804b73

Please sign in to comment.