Git Product home page Git Product logo

deployhook's Introduction

Deploy Hook

Node.js express app to receive github and bitbucket Git POST hook and automate code deployment.

What Deploy Hook is

Deploy Hook is is just simple Node.js git pull application triggered by git hosting hook notifications.

How to use

  • Set git repository for your apps in both your development machine and deployment server
  • Set SSH keys in both machines
  • Clone deploy hook app
  • Adjust config.js
  • Run deploy hook app in your server
  • Set Hook url on your git hosting (github or bitbucket)
  • See notes below
  • Commit and enjoy

Config file

When execute with Node.js exec, git run on different environment than you usual command line bash. Make sure you set correct gitPath and keyPath in config.js. I tested this on my machine on Windows 7 32 bit and Windows Server 2012 64 bit. You might need to modify config file and path accordingly.

Update (how to setup Git key path)

My applications are running on IIS with iisnode. It turns out that even with setting keyPath directly git pull just won't work. One solution is to copy .ssh folder from HOME directory (Usually something like : C:\Users\Administrator\.ssh) into your Git installation path C:\Program Files (x86)\Git\.ssh.

With above approach you can use git pull origin master directly. Apparently when executed with Node.js exec(), git looks for SSH keys in C:\Program Files (x86)\Git\.ssh folder.

POST hook url

Note that this app has basic auth in it. So your POST hook url should be like https://user:password@serverhost:serverport/helper/v1/deploy/hook

Customize deployment

If you see function deploy in deploy.js you will notice that I separate staging and production deployment using branch information from github Webhook body or bitbucket POST hook body.

I also include sample payload in function getHook in deploy.js. You can create your own custom deployment suitable for your needs and use POST body accordingly

Public repository use

This code is intended for private repository as it's using SSH key. If you have public repository you can skip SSH config settings.

License

MIT

deployhook's People

Contributors

arifsetiawan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.