Giter VIP home page Giter VIP logo

githubhook's Introduction

GitHub Post-Receive Deployment Hook

Deploying applications to development, staging and production never been so easy with GitHub Post-Receive Deployment Hook script!

Installation

Clone the script:

$ git clone https://github.com/kwangchin/GitHubHook.git

Go to your GitHub repo > Admin > Service Hooks, select Post-Receive URLS and enter your hook URL like this:

GitHub Post-Receive URLs

How It Works

GitHub provides Post-Receive Hooks to allow HTTP callback with a HTTP Post. We then create a script for the callback to deploy the systems automatically.

You will need to create branches like stage and prod in Git before proceeding into the configurations.

You then can have a brief look into hook.php, a WebHook example provided for you to experience how simple the configurations are.

<?php
require_once('class.GitHubHook.php');

// Initiate the GitHub Deployment Hook
$hook = new GitHubHook;

// Enable the debug log (sent to error_log) 
$hook->enableDebug();

// Adding `stage` branch to deploy for `staging` to path `/var/www/testhook/stage`
$hook->addBranch('stage', 'staging', '/var/www/stage');

// Adding `prod` branch to deploy for `production` to path `/var/www/testhook/prod`
$hook->addBranch('prod', 'production', '/var/www/prod', array('[email protected]'));

// Deploy the commits
$hook->deploy();

In this example, we enabled the debug log for messages with timestamp. You can disable this by commenting or removing the line $hook->enableDebug()

We have a staging site and a production site in this example. You can add more branches easily with $hook->addBranch() method if you have more systems to deploy.

We then use $hook->deploy() to deploy the systems.

Security

Worry about securities? We have enabled IP check to allow only GitHub hook addresses (CIDR notation): 192.30.252.0/22 to deploy the systems. We also return a 404 Not Found page when there is illegal access to the hook script.

For better security, try hiding this hook script in deep directories like http://www.example.com/let/us/play/hide/and/seek/ and/or renaming the hook.php file into a40b6cf7a5.php.

For Developers

We are trying to make developers life easier. Kindly fork this on GitHub and submit your pull requests to help us.

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.