Skip to content

Commit 66e871f

Browse files
authored
Update README.md
1 parent 7c29cf4 commit 66e871f

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

README.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
#Webhook
1+
# Webhook
2+
23
Wrappers and webservice to handle [Github Webhook requests](https://developer.github.com/webhooks/).
34

45
[Webhook Project Homepage](https://github.com/katmore/webhook)
56

6-
##Description
7+
## Description
78
The Webhook Project facilitates workflow integration of Github Webhook requests. It provides [class wrappers](#wrapper-classes) for existing projects and an optional [end-point installer script](#end-point-installer-script) for a self-contained solution that is easy to deploy.
89

9-
##Requirements
10+
## Requirements
1011
* PHP 7.0 or higher
1112

12-
##Usage
13-
###End-point Installer Script
13+
## Usage
14+
### End-point Installer Script
1415
The command-line script [bin/add-endpoint.php](bin/add-endpoint.php) creates a webservice end-point that responds to a Github Webhook for the **PushEvent** on a remote repository by updating a local repository and to a **PingEvent** by displaying a success message.
1516

1617
The simplest way to prepare the end-point installer is to copy this project somewhere and run Composer:
@@ -29,7 +30,7 @@ The `--help` switch will provide details on more advanced usage (such as quiet a
2930
php bin/add-endpoint.php --help
3031
```
3132

32-
###Wrapper Classes
33+
### Wrapper Classes
3334
To use this project's wrapper classes within your existing project, the main topics of focus will be the [**Webhook\Request** class](src/Request.php) and **Payload** objects. As a recomended first step, add a dependancy using Composer to your existing project:
3435
```bash
3536
composer require katmore/webhook
@@ -82,7 +83,7 @@ $payload = $request->getPayload();
8283
*/
8384
var_dump($payload);
8485
```
85-
###Validating a request's "Hub Signature"
86+
### Validating a request's "Hub Signature"
8687
At some point in the handling of a Webhook request it is critical that the "Hub Signature" be validated against the shared "Secret" for obvious security reasons. The [end-point installer](#endpoint-installer-script) and [end-point example](#endpoint-installer-script) both accomplish this by using the **Callback::validateRequest()** method of the [**Webhook\Callback** class](src/Callback.php). However, there may be situations where it is more practical to implement validation natively with the [`hash_hmac()` function](http://php.net/manual/en/function.hash-hmac.php) as shown in the example below:
8788

8889
```php
@@ -115,38 +116,38 @@ if ($hash !== hash_hmac($algo, $messageBody, $hubSecret)) {
115116
*/
116117
```
117118

118-
###Using the provided end-point example
119+
### Using the provided end-point example
119120

120121
An end-point example is provided at [web/endpoint-example.php](web/endpoint-example.php) which responds to a **PushEvent** by invoking 'pull' or 'update' commands on a local git or svn repository as appropriate. It also responds to a a **PingEvent** with a success message.
121122

122123
* copy the provided [web/endpoint-example.php](web/endpoint-example.php)...
123124

124125
```bash
125-
cp web/endpoint-example.php web/my-org/my-repo.php
126-
```
126+
cp web/endpoint-example.php web/my-org/my-repo.php
127+
```
127128
* edit "web/my-org/my-repo.php" to specify configuration...
128129
* change the value of `$config['RepoUrl']` to your GitHub repository URL:
129130

130131
```php
131-
$config['RepoUrl'] = 'https://github.com/my-organization/my-repo';
132-
```
132+
$config['RepoUrl'] = 'https://github.com/my-organization/my-repo';
133+
```
133134
* change the value of `$config['Secret']` to the "Secret" configured in Github for the webhook:
134135

135136
```php
136-
$config['Secret'] = 'My Secret';
137-
```
137+
$config['Secret'] = 'My Secret';
138+
```
138139
* change the value of `$config['RepoPath']` the local system path to the repository:
139140

140141
```php
141-
$config['RepoPath'] = '/path/to/my/repo';
142-
```
142+
$config['RepoPath'] = '/path/to/my/repo';
143+
```
143144
* change the value of `$config['RepoType']` to either 'git' or 'svn', depending on the local repository type:
144145

145146
```php
146-
$config['RepoType'] = 'git';
147-
```
147+
$config['RepoType'] = 'git';
148+
```
148149

149-
##Legal
150+
## Legal
150151
"Webhook" is distributed under the terms of the [MIT license](LICENSE) or the [GPLv3](GPLv3) license.
151152

152153
Copyright (c) 2016, Doug Bird.

0 commit comments

Comments
 (0)