Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cde8ef6

Browse files
Callbacks for error and success
1 parent 13a7085 commit cde8ef6

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

‎deploy-config.orig.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,10 @@
115115
* However, intermediate files would not be cleaned up from TARGET_DIR
116116
*/
117117
define('CLEANUP_WORK_TREE', false);
118+
119+
/* CALLBACK_FILE:
120+
* Filename of a PHP script containing callback functions to
121+
* be triggered at the end of the script on success or failure.
122+
* Useful to connect to your preferred notification system.
123+
*/
124+
define('CALLBACK_FILE', '');

‎deploy.php‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ function endScript($msg = "") {
5151
if(defined('LOG_FILE') && LOG_FILE !== '') error_log($output, 3, LOG_FILE);
5252
// Send email notification
5353
if(defined('EMAIL_NOTIFICATIONS') && EMAIL_NOTIFICATIONS !== '') error_log($output, 1, EMAIL_NOTIFICATIONS);
54+
// Send error callback
55+
if($msg && defined('CALLBACK_FILE') && file_exists(CALLBACK_FILE)){
56+
require_once CALLBACK_FILE;
57+
if(function_exists(callbackError)) {
58+
callbackError($msg);
59+
}
60+
}
5461
die($msg);
5562
}
5663

@@ -475,6 +482,18 @@ function cmd($command, $print = true, $dir = GIT_DIR) {
475482
, $checkout
476483
, TARGET_DIR . 'VERSION'
477484
));
485+
486+
// Send success callback
487+
if(defined('CALLBACK_FILE') && file_exists(CALLBACK_FILE)){
488+
require_once CALLBACK_FILE;
489+
if(function_exists(callbackSuccess)) {
490+
callbackSuccess(array(
491+
'branch' => $branch,
492+
'commit' => $checkout,
493+
'execTime' => $time + microtime(true)
494+
));
495+
}
496+
}
478497
?>
479498

480499
Done in <?php echo $time + microtime(true); ?>sec

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /