forked from lkwdwrd/git-deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitbucket.php
34 lines (32 loc) · 1.1 KB
/
bitbucket.php
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
29
30
31
32
33
34
<?php
// Make sure we have a payload, stop if we do not.
if( ! isset( $_POST['payload'] ) )
die( '<h1>No payload present</h1><p>A BitBucket POST payload is required to deploy from this script.</p>' );
/**
* Tell the script this is an active end point.
*/
define( 'ACTIVE_DEPLOY_ENDPOINT', true );
require_once 'deploy-config.php';
/**
* Deploys BitBucket git repos
*/
class BitBucket_Deploy extends Deploy {
/**
* Decodes and validates the data from bitbucket and calls the
* deploy constructor to deploy the new code.
*
* @param string $payload The JSON encoded payload data.
*/
function __construct( $payload ) {
$payload = json_decode( stripslashes( $_POST['payload'] ), true );
$name = $payload['repository']['name'];
$this->log( $payload['commits'][0]['branch'] );
if ( isset( parent::$repos[ $name ] ) && parent::$repos[ $name ]['branch'] === $payload['commits'][0]['branch'] ) {
$data = parent::$repos[ $name ];
$data['commit'] = $payload['commits'][0]['node'];
parent::__construct( $name, $data );
}
}
}
// Start the deploy attempt.
new BitBucket_Deploy( $_POST['payload'] );