You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
GitHub provides [Post-Receive Hooks](http://help.github.com/post-receive-hooks/) to allow HTTP callback with a HTTP Post. We then create a script for the callback to deploy the systems automatically.
19
+
20
+
You will need to create branches like `stage` and `prod` in Git before proceeding into the configurations.
21
+
22
+
You then can have a brief look into `hook.php`, a WebHook example provided for you to experience how simple the configurations are.
23
+
24
+
<pre><code><?php
25
+
require_once('class.GitHubHook.php');
26
+
27
+
// Initiate the GitHub Deployment Hook
28
+
$hook = new GitHubHook;
29
+
30
+
// Enable the debug log, kindly make `log/hook.log` writable
31
+
$hook->enableDebug();
32
+
33
+
// Adding `stage` branch to deploy for `staging` to path `/var/www/testhook/stage`
In this example, we enabled the debug log for messages with timestamp. You can disable this by commenting or removing the line `$hook->enableDebug()`
44
+
45
+
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.
46
+
47
+
We then use `$hook->deploy()` to deploy the systems.
48
+
49
+
##
50
+
51
+
### Security
52
+
53
+
Worry about securities? We have enabled IP check to allow only GitHub hook addresses: `207.97.227.253`, `50.57.128.197` to deploy the systems. We also return a `404 Not Found` page when there is illegal access to the hook script.
54
+
55
+
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`.
56
+
57
+
### For Developers
58
+
59
+
We are trying to make developers life easier. Kindly fork this on GitHub and submit your pull requests to help us.
0 commit comments