forked from kestasjk/webDiplomacy
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathgitpull.php
More file actions
29 lines (20 loc) · 739 Bytes
/
gitpull.php
File metadata and controls
29 lines (20 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
// Receive webhook requests from github to allow quick publish and test
// Set GITWEBHOOKSECRET in the Apache config files with SetEnv
$headers = apache_request_headers();
if( !isset($headers['X-Hub-Signature-256']) )
{
if( isset($_REQUEST['log']) )
die(file_get_contents('../gitpull.log'));
else
die('Unauthorized');
}
$rawReq = file_get_contents('php://input');
$sig_check = 'sha256=' . hash_hmac('sha256', $rawReq, getenv('GITWEBHOOKSECRET'));
if (!hash_equals($sig_check, $headers['X-Hub-Signature-256']))
{
die("Access denied, request logged");
}
// This is an authenticated notification from github that we need to pull.
shell_exec('date >> ../gitpull.log 2>&1');
shell_exec('git pull >> ../gitpull.log 2>&1');