danheberden / gith Goto Github PK
View Code? Open in Web Editor NEWsimple node server that responds to github post-receive events with meaningful data
License: MIT License
simple node server that responds to github post-receive events with meaningful data
License: MIT License
See https://api.github.com/meta for current list of ips!
More info here: http://developer.github.com/v3/meta/
Maybe fetch the list on app-start?
Can we expect this project to be updated? Its a very useful app but hasn't had critical updates, like the data format change, applied so the main version has become out of date.
Are there any workarounds for bitbucket? Anyone working on adding support for bitbucket?
I'm trying to use gith with bitbucket.
Bitbucket sends payload with lot of '+' characters in payload data. which should be decoded to ' ' (space character) I believe.
But gith uses the character as such and eventually json decoding fails.
I have inspected the hook post with requestb.in and attached the screenshot. I have also attached the error screenshot.
From the initial blog post about gith
:
There are more features planned and unit tests to write, but we wanted you to see it as soon as possible and have an opportunity to get involved and give feedback. This is what I’m planning to attack in the immediate future:
- Supporting github API calls with OAuth
- ...
Support GitHub API calls with OAuth
The feature that I want added most if definitely integration to support GitHub API calls with OAuth, which can probably be easily achieved by depending on the [unofficial] github
module.
I have beem attempting to implement git hooks with gith have had no luck.
Even the very simple example below does not behave as I would expect.
Status code 200 is being returned to github, so the gith server
is obviously running, but the callback is not ever being called.
var gith = require('gith').create(9004); // ensure to match the port you entered in Github
gith().on( 'all', function( payload ) {
console.log( 'Post-receive happened!' );
});
For the record I'm using Ubuntu 14.04 x64
We have a situation where we have multiple platforms that all have a 'master' branch, that trigger their own build job on our CI machines. Each platform has its own repository on Github.
It turns out that a change on 'master' to one of the repo's ends up triggering the payload for all repositories with the same branch name.
As a workaround, we are double checking the value of payload.repo
against the repo we're supposed to receive the hook from.
Need to test things like
gith({
repo: function( payload ) {
return /gith/.test( payload.repo );
}
}).on( 'all', function( payload ) {
/* do stuff */
});
and create/test
gith( function( payload ) {
/* check payload for stuff */
this.emit( 'customevent', payload );
}).on( 'customevent', function( payload ) {
/* yay! */
});
Add support for something like myserver.com:9001/?secret=cantguessme
so that people can't send hand-crafted payloads to a server.
Poll for new repos and auto-subscribe them.
From the initial blog post about gith
:
There are more features planned and unit tests to write, but we wanted you to see it as soon as possible and have an opportunity to get involved and give feedback. This is what I’m planning to attack in the immediate future:
- ...
- Polling an account for new repositories and automatically subscribing them to the WebHook url
- ...
Since GitHub specifies from which IPs they will send the request, gith should only accept data from these (and optionally some specified ones)
The Public IP addresses for these hooks are:
207.97.227.253,
50.57.128.197,
108.171.174.178,
50.57.231.61.
This info can be found under Settings > Service Hooks > WebHook URLs
I receive this error when receiving data from github...
Application has thrown an uncaught exception and is terminated:
SyntaxError: Unexpected token %
at Object.parse (native)
at IncomingMessage. (C:\DWASFiles\Sites\gitcopy\VirtualDirectory0\site\wwwroot\node_modules\gith\lib\gith.js:235:28)
at IncomingMessage.emit (events.js:64:17)
at HTTPParser.parserOnMessageComplete as onMessageComplete
at Socket.ondata (http.js:1506:22)
at Pipe.onread (net.js:374:27)
This is caused by the data being querystring escaped. I have a pull request with a fix that I'll be submitting.
This project needs some serious overhaul.
require_once("moar-php.php");
It would be quite cool it if were possible to execute a gith
-command that automatically starts a new server based on a configuration file, much in the same way that tools like gulp
and grunt
do it.
The configuration file could even have some default locations, like $PWD/gith.js
, ~/.gith.js
or /etc/gith/gith.js
. It would also make the configuration file a bit more declarative.
Because they are in the "head_commit" portion of the payload and not "commits" :/
Does this library even still work for anyone? In version 1.04 I am able to receiving POSTs from github webhooks, but they all seem to be failing this payload regular expression test.
req.on( "end", function() {
if ( /^payload=/.test( data ) ) {
var payload = JSON.parse( querystring.unescape(data.slice(8)) );
eventaur.emit( "payload", payload );
res.writeHead( 200, {
'Content-type': 'text/html'
});
}
res.end();
});
However if I edit gith to just expect the payload and not playload={ /* data */ }
, then it works.
req.on( "end", function() {
var payload;
try {
payload = JSON.parse( data );
eventaur.emit( "payload", payload );
res.writeHead( 200, {
'Content-type': 'text/html'
});
} catch(err) {
console.log(err);
}
res.end();
});
Has anyone else had issues?
node 8.9, connectivity confirmed, testing from github hook panel (Test Hook button)
For some obscur reason, the end event is not being called.
gith.js
this.server = http.createServer( function( req, res ) {
var data = "";
if ( req.method === "POST" ) {
req.on( "data", function( chunk ) {
/// I DO SEE CHUNK BEING APPENED TO DATA
data += chunk;
});
}
req.on( "end", function() { // <<--- THIS GUY NEVER GETS CALLED
if ( /^payload=/.test( data ) ) {
var payload = JSON.parse( querystring.unescape(data.slice(8)) );
eventaur.emit( "payload", payload );
}
res.end();
});
res.writeHead( 200, {
'Content-type': 'text/html'
});
res.end();
}).listen( port );
Since end doesn't get called, gith just never picks up any message....
Add secret query param to prevent false payloads.
From the initial blog post about gith
:
There are more features planned and unit tests to write, but we wanted you to see it as soon as possible and have an opportunity to get involved and give feedback. This is what I’m planning to attack in the immediate future:
- ...
- Specifying a secret query-string-argument in the url (e.g., ?secret=password) to prevent the server from receiving false payloads
Not quite sure how this should look, but some way to log events would be awes
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.