forked from benr77/BitbucketCronDeploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitbucket-cron-deploy.php
37 lines (30 loc) · 1.21 KB
/
bitbucket-cron-deploy.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
35
<?php
/**
* Git Deployment Script for BitBucket
*
* All the existing PHP Git deploy scripts seem to rely on the repository copy on the web server,
* and the web site files themselves, all being writable by the web server user (e.g. apache or www-data).
* From a security point of view this is far from ideal.
*
* This script does pretty much the same as the others, except it can also be called via cron.
* Symlink it in to web space and create your URL for a BitBucket Hook POST Request. Hits to this URL from
* BitBucket will cause an empty file to be written.
*
* Then, cron the script to run every minute or whatever. When run from cron, it looks for the above file.
* If it finds it, it does the Git checkout under the permissions of the system user account and NOT the
* web server user. Once this is done it deletes the data file.
*
* @Author: Ben Roberts ben@headsnet.com
*
*/
// Include the class
include 'class.bitbucket-cron-deploy.php';
include 'config.php';
// Instantiate a new instance
$myDeploy = new cronDeploy();
// Set config vars
$myDeploy->setRepoPath($repo_path);
$myDeploy->setRootPath($root_path);
$myDeploy->setGitBranch($git_branch);
// Run the deployment
$myDeploy->deploy();