Skip to content

Latest commit

 

History

History
23 lines (18 loc) · 715 Bytes

README.md

File metadata and controls

23 lines (18 loc) · 715 Bytes

uphook

express middleware to automatically update and restart an application based on github/gitlab webhook.

npm install --save uphook

usage

if verified hook on right branch, git force-pulls to current branch and calls the callback.

let hook = require('uphook').github({
  secret: process.env.GH_SECRET,
  verify: function(req, res){
    return true;
    //before it calls gitupdate(), can return false to cancel that.
  },
  callback: function(err, payload){
    if(!err)
      process.exit(0); //lets PM2 restart the process
  }
});
app.use('/gh-update', hook);

note that you should definitely use SSL because GitLab doesn't have HMAC, which is dumb.