Skip to content

Commit

Permalink
Commit new files
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinlarimer committed Oct 11, 2017
1 parent f10f91c commit b351ed5
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .env-sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
KEEN_PROJECT_ID=
KEEN_WRITE_KEY=
GITHUB_ACCESS_KEY=
GITHUB_ORG=
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.env
.DS_STORE
73 changes: 73 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const env = require('dotenv').config();
const github = require('octonode');
const options = {
keen: {
projectId: process.env.KEEN_PROJECT_ID,
writeKey: process.env.KEEN_WRITE_KEY
},
github: {
accessToken: process.env.GITHUB_ACCESS_TOKEN,
orgs: process.env.GITHUB_ORG.split(','),
events: [
'commit_comment',
'create',
'delete',
'deployment',
'deployment_status',
'fork',
'gollum',
'installation',
'installation_repositories',
'issue_comment',
'issues',
'label',
'marketplace_purchase',
'member',
'membership',
'milestone',
'organization',
'org_block',
'page_build',
'project_card',
'project_column',
'project',
'public',
'pull_request_review_comment',
'pull_request_review',
'pull_request',
'push',
'repository',
'release',
'status',
'team',
'team_add',
'watch'
]
}
};

options.github.orgs.forEach((org) => {
options.github.events.forEach((eventType) => {
let url = `https://api.keen.io/3.0/projects/${options.keen.projectId}`;
url += `/events/${eventType}?api_key=${options.keen.writeKey}`;
github
.client(options.github.accessToken)
.org(org)
.hook({
name: 'web',
active: true,
events: [ eventType ],
config: {
url: url,
content_type: 'json'
}
}, (err, res) => {
if (err) {
console.log(err.statusCode + ' ' + err.message);
}
else {
console.log('Webhook created: ' + res.events[0] + ' (' + res.active + ')');
}
});
});
});
24 changes: 24 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "keen-github-analytics",
"version": "1.0.0",
"description": "GitHub Analytics by Keen IO",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/keen/github-analytics.git"
},
"author": "Dustin Larimer <dustin@keen.io>",
"license": "MIT",
"bugs": {
"url": "https://github.com/keen/github-analytics/issues"
},
"homepage": "https://github.com/keen/github-analytics#readme",
"devDependencies": {
"dotenv": "^4.0.0",
"octonode": "^0.8.0"
}
}

0 comments on commit b351ed5

Please sign in to comment.