Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save miguel-serrano/996e3a716987e4adbc54 to your computer and use it in GitHub Desktop.
Save miguel-serrano/996e3a716987e4adbc54 to your computer and use it in GitHub Desktop.
Two CodeIgniter methods that you can use to get your Beanstalk deploy notifications into Notify.io
function pre(){
$this->load->library('notifyio_api');
$handle = fopen('php://input','r');
$jsonInput = fgets($handle);
$decoded = json_decode($jsonInput,true);
fclose($handle);
$data = array(
'email'=>$decoded['author_email'],
'text'=>'Revision ('.$decoded['revision'].') started for ['.$decoded['repository'].'] to ['.$decoded['server'].']',
'title'=>'Deployment Started',
'link'=>$decoded['repository_url'],
'icon'=>YOUR ICON
);
$this->notifyio_api->send_notification($data);
}
function post(){
$this->load->library('notifyio_api');
date_default_timezone_set('Europe/London');
$handle = fopen('php://input','r');
$jsonInput = fgets($handle);
$decoded = json_decode($jsonInput,true);
fclose($handle);
$deploy_time = date("H:i",strtotime($decoded['deployed_at']));
$data = array(
'email'=>$decoded['author_email'],
'text'=>'Revision ('.$decoded['revision'].') finished for ['.$decoded['repository'].'] to ['.$decoded['server'].'] ('.$deploy_time.')',
'title'=>'Deployment Finished',
'link'=>$decoded['repository_url'],
'icon'=>YOUR ICON
);
$this->notifyio_api->send_notification($data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment