const WebhooksApi = require('@octokit/webhooks')
const webhooks = new WebhooksApi({
secret: 'secret'
})
webhooks.on('push', async () => {
console.log('ok')
})
const payload = {
'ref': 'refs/heads/master',
'before': 'b633938b836945c5cd5db895b7d631223d0cbde7',
'after': '8faa98ea3fa235415d4c0400376bbe0995b9e995',
'created': false,
'deleted': false,
'forced': false,
'base_ref': null,
'compare': 'https://github.com/YChebotaev/prizmo/compare/b633938b8369...8faa98ea3fa2',
'commits': [
{
'id': '8faa98ea3fa235415d4c0400376bbe0995b9e995',
'tree_id': 'c521ac55c8c0c0fc85af51ef841b3e4b307ff65e',
'distinct': true,
'message': 'Добавил процедуру удаления конверсий',
'timestamp': '2019-04-21T07:04:21+05:00',
'url': 'https://github.com/YChebotaev/prizmo/commit/8faa98ea3fa235415d4c0400376bbe0995b9e995',
'author': {
'name': 'Yury Chebotaev',
'email': '
[email protected]',
'username': 'YChebotaev'
},
'committer': {
'name': 'Yury Chebotaev',
'email': '
[email protected]',
'username': 'YChebotaev'
},
'added': [
'packages/prizmo-service/clickhouse.js'
],
'removed': [
],
'modified': [
'packages/prizmo-service/jobs.js',
'packages/prizmo-service/lib/classes/TrackConversion.js',
'packages/prizmo-service/models/schema/conversion.js',
'packages/prizmo-service/package-lock.json',
'packages/prizmo-service/package.json'
]
}
],
'head_commit': {
'id': '8faa98ea3fa235415d4c0400376bbe0995b9e995',
'tree_id': 'c521ac55c8c0c0fc85af51ef841b3e4b307ff65e',
'distinct': true,
'message': 'Добавил процедуру удаления конверсий',
'timestamp': '2019-04-21T07:04:21+05:00',
'url': 'https://github.com/YChebotaev/prizmo/commit/8faa98ea3fa235415d4c0400376bbe0995b9e995',
'author': {
'name': 'Yury Chebotaev',
'email': '
[email protected]',
'username': 'YChebotaev'
},
'committer': {
'name': 'Yury Chebotaev',
'email': '
[email protected]',
'username': 'YChebotaev'
},
'added': [
'packages/prizmo-service/clickhouse.js'
],
'removed': [
],
'modified': [
'packages/prizmo-service/jobs.js',
'packages/prizmo-service/lib/classes/TrackConversion.js',
'packages/prizmo-service/models/schema/conversion.js',
'packages/prizmo-service/package-lock.json',
'packages/prizmo-service/package.json'
]
},
'repository': {
'id': 181070893,
'node_id': 'MDEwOlJlcG9zaXRvcnkxODEwNzA4OTM=',
'name': 'prizmo',
'full_name': 'YChebotaev/prizmo',
'private': true,
'owner': {
'name': 'YChebotaev',
'email': '
[email protected]',
'login': 'YChebotaev',
'id': 5302856,
'node_id': 'MDQ6VXNlcjUzMDI4NTY=',
'avatar_url': 'https://avatars3.githubusercontent.com/u/5302856?v=4',
'gravatar_id': '',
'url': 'https://api.github.com/users/YChebotaev',
'html_url': 'https://github.com/YChebotaev',
'followers_url': 'https://api.github.com/users/YChebotaev/followers',
'following_url': 'https://api.github.com/users/YChebotaev/following{/other_user}',
'gists_url': 'https://api.github.com/users/YChebotaev/gists{/gist_id}',
'starred_url': 'https://api.github.com/users/YChebotaev/starred{/owner}{/repo}',
'subscriptions_url': 'https://api.github.com/users/YChebotaev/subscriptions',
'organizations_url': 'https://api.github.com/users/YChebotaev/orgs',
'repos_url': 'https://api.github.com/users/YChebotaev/repos',
'events_url': 'https://api.github.com/users/YChebotaev/events{/privacy}',
'received_events_url': 'https://api.github.com/users/YChebotaev/received_events',
'type': 'User',
'site_admin': false
},
'html_url': 'https://github.com/YChebotaev/prizmo',
'description': null,
'fork': false,
'url': 'https://github.com/YChebotaev/prizmo',
'forks_url': 'https://api.github.com/repos/YChebotaev/prizmo/forks',
'keys_url': 'https://api.github.com/repos/YChebotaev/prizmo/keys{/key_id}',
'collaborators_url': 'https://api.github.com/repos/YChebotaev/prizmo/collaborators{/collaborator}',
'teams_url': 'https://api.github.com/repos/YChebotaev/prizmo/teams',
'hooks_url': 'https://api.github.com/repos/YChebotaev/prizmo/hooks',
'issue_events_url': 'https://api.github.com/repos/YChebotaev/prizmo/issues/events{/number}',
'events_url': 'https://api.github.com/repos/YChebotaev/prizmo/events',
'assignees_url': 'https://api.github.com/repos/YChebotaev/prizmo/assignees{/user}',
'branches_url': 'https://api.github.com/repos/YChebotaev/prizmo/branches{/branch}',
'tags_url': 'https://api.github.com/repos/YChebotaev/prizmo/tags',
'blobs_url': 'https://api.github.com/repos/YChebotaev/prizmo/git/blobs{/sha}',
'git_tags_url': 'https://api.github.com/repos/YChebotaev/prizmo/git/tags{/sha}',
'git_refs_url': 'https://api.github.com/repos/YChebotaev/prizmo/git/refs{/sha}',
'trees_url': 'https://api.github.com/repos/YChebotaev/prizmo/git/trees{/sha}',
'statuses_url': 'https://api.github.com/repos/YChebotaev/prizmo/statuses/{sha}',
'languages_url': 'https://api.github.com/repos/YChebotaev/prizmo/languages',
'stargazers_url': 'https://api.github.com/repos/YChebotaev/prizmo/stargazers',
'contributors_url': 'https://api.github.com/repos/YChebotaev/prizmo/contributors',
'subscribers_url': 'https://api.github.com/repos/YChebotaev/prizmo/subscribers',
'subscription_url': 'https://api.github.com/repos/YChebotaev/prizmo/subscription',
'commits_url': 'https://api.github.com/repos/YChebotaev/prizmo/commits{/sha}',
'git_commits_url': 'https://api.github.com/repos/YChebotaev/prizmo/git/commits{/sha}',
'comments_url': 'https://api.github.com/repos/YChebotaev/prizmo/comments{/number}',
'issue_comment_url': 'https://api.github.com/repos/YChebotaev/prizmo/issues/comments{/number}',
'contents_url': 'https://api.github.com/repos/YChebotaev/prizmo/contents/{+path}',
'compare_url': 'https://api.github.com/repos/YChebotaev/prizmo/compare/{base}...{head}',
'merges_url': 'https://api.github.com/repos/YChebotaev/prizmo/merges',
'archive_url': 'https://api.github.com/repos/YChebotaev/prizmo/{archive_format}{/ref}',
'downloads_url': 'https://api.github.com/repos/YChebotaev/prizmo/downloads',
'issues_url': 'https://api.github.com/repos/YChebotaev/prizmo/issues{/number}',
'pulls_url': 'https://api.github.com/repos/YChebotaev/prizmo/pulls{/number}',
'milestones_url': 'https://api.github.com/repos/YChebotaev/prizmo/milestones{/number}',
'notifications_url': 'https://api.github.com/repos/YChebotaev/prizmo/notifications{?since,all,participating}',
'labels_url': 'https://api.github.com/repos/YChebotaev/prizmo/labels{/name}',
'releases_url': 'https://api.github.com/repos/YChebotaev/prizmo/releases{/id}',
'deployments_url': 'https://api.github.com/repos/YChebotaev/prizmo/deployments',
'created_at': 1555097099,
'updated_at': '2019-04-21T01:37:48Z',
'pushed_at': 1555812268,
'git_url': 'git://github.com/YChebotaev/prizmo.git',
'ssh_url': '
[email protected]:YChebotaev/prizmo.git',
'clone_url': 'https://github.com/YChebotaev/prizmo.git',
'svn_url': 'https://github.com/YChebotaev/prizmo',
'homepage': null,
'size': 1279,
'stargazers_count': 0,
'watchers_count': 0,
'language': 'JavaScript',
'has_issues': false,
'has_projects': false,
'has_downloads': true,
'has_wiki': false,
'has_pages': false,
'forks_count': 0,
'mirror_url': null,
'archived': false,
'disabled': false,
'open_issues_count': 0,
'license': null,
'forks': 0,
'open_issues': 0,
'watchers': 0,
'default_branch': 'master',
'stargazers': 0,
'master_branch': 'master'
},
'pusher': {
'name': 'YChebotaev',
'email': '
[email protected]'
},
'sender': {
'login': 'YChebotaev',
'id': 5302856,
'node_id': 'MDQ6VXNlcjUzMDI4NTY=',
'avatar_url': 'https://avatars3.githubusercontent.com/u/5302856?v=4',
'gravatar_id': '',
'url': 'https://api.github.com/users/YChebotaev',
'html_url': 'https://github.com/YChebotaev',
'followers_url': 'https://api.github.com/users/YChebotaev/followers',
'following_url': 'https://api.github.com/users/YChebotaev/following{/other_user}',
'gists_url': 'https://api.github.com/users/YChebotaev/gists{/gist_id}',
'starred_url': 'https://api.github.com/users/YChebotaev/starred{/owner}{/repo}',
'subscriptions_url': 'https://api.github.com/users/YChebotaev/subscriptions',
'organizations_url': 'https://api.github.com/users/YChebotaev/orgs',
'repos_url': 'https://api.github.com/users/YChebotaev/repos',
'events_url': 'https://api.github.com/users/YChebotaev/events{/privacy}',
'received_events_url': 'https://api.github.com/users/YChebotaev/received_events',
'type': 'User',
'site_admin': false
}
}
webhooks.verifyAndReceive({
signature: webhooks.sign(payload),
id: 'cbbcc566-63d9-11e9-9dc2-8901b1d8e691',
name: 'push',
payload
})