Adding Github statuses integration

This commit is contained in:
Dan Cryer 2013-05-14 17:49:39 +01:00
parent 812dfcb95a
commit 918b4deff4
4 changed files with 9 additions and 6 deletions

View file

@ -94,7 +94,7 @@ class ProjectController extends b8\Controller
$pub = file_get_contents($id . '.pub');
$prv = file_get_contents($id);
$values = array('key' => $prv, 'pubkey' => $pub);
$values = array('key' => $prv, 'pubkey' => $pub, 'token' => $_SESSION['github_token']);
}
$form = $this->projectForm($values);
@ -201,7 +201,6 @@ class ProjectController extends b8\Controller
if(isset($_SESSION['github_token']))
{
$field = new Form\Element\Select('github');
$field->setPattern('[a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+');
$field->setLabel('Choose a Github repository:');
$field->setClass('span4');
$field->setOptions($this->getGithubRepositories());

View file

@ -53,6 +53,7 @@ class SessionController extends b8\Controller
public function logout()
{
unset($_SESSION['user_id']);
unset($_SESSION['github_token']);
header('Location: /');
die;
}

View file

@ -40,7 +40,7 @@ class Build extends BuildBase
if($project->getType() == 'github' && $project->getToken())
{
$url = 'https://api.github.com/repos/'.$project->getReference().'/statuses/'.$this->build->getCommitId() . '?access_token=' . $project->getToken();
$url = 'https://api.github.com/repos/'.$project->getReference().'/statuses/'.$this->getCommitId();
$http = new \b8\HttpClient();
switch($this->getStatus())
@ -63,8 +63,11 @@ class Build extends BuildBase
break;
}
$params = array('status' => $status, 'target_url' => \b8\Registry::getInstance()->get('install_url') . '/build/view/' . $this->getId());
$http->post($url, $params);
$params = array( 'state' => $status,
'target_url' => \b8\Registry::getInstance()->get('install_url') . '/build/view/' . $this->getId());
$http->setHeaders(array('Authorization: token ' . $project->getToken()));
$http->request('POST', $url, json_encode($params));
}
}
}

View file

@ -17,6 +17,6 @@ class Composer implements \PHPCI\Plugin
public function execute()
{
return $this->phpci->executeCommand(PHPCI_DIR . 'composer.phar --working-dir=' . $this->directory . ' ' . $this->action);
return $this->phpci->executeCommand(PHPCI_DIR . 'composer.phar --prefer-dist --working-dir=' . $this->directory . ' ' . $this->action);
}
}