public function sendStatus($siteId, $token, $git_url, $commit, $status, $message) { try { $pattern = '/:([\\w\\d-_\\.]+\\/[\\w\\d-_\\.]+)\\.git$/i'; if (preg_match($pattern, $git_url, $matchs)) { if (empty($token)) { Log::info("Site {$siteId} github token dosen't confiured"); return ''; } $client = new \Eleme\Github\GithubClient($token); $response = $client->request('repos/' . $matchs[1] . '/statuses/' . $commit, json_encode(array('state' => $status, "target_url" => url("/{$siteId}/pull_request/info"), "description" => $message, "context" => "eleme deploy")), true); Log::info("Send Status To Github: {$status}"); } else { Log::info("Send Status Error, Can't Find Full Repo Name: {$git_url}"); } } catch (Exception $e) { Log::info($e); Log::info($e->getResponse()->getBody(true)); Log::info("Send Status Error"); } }
return Redirect::to('/github/oauth/confirm')->withCookie($cookie); }); Route::get('/github/oauth/callback', function () { if (GithubLogin::check()) { return Redirect::to('/'); } $code = Input::get('code'); if ($code == '') { return 'CODE ERROR'; } $accessToken = \Eleme\Github\GithubAuthorize::accessToken($code); if ($accessToken == NULL) { echo "CODE ERROR"; } $client = new \Eleme\Github\GithubClient($accessToken); $teams = $client->request('user/teams'); $haveEleme = false; $orgTeams = array(); foreach ($teams as $team) { if ($team->organization->login == Config::get('github.organization')) { $haveEleme = true; $orgTeams[] = $gt = new GithubTeam($team); TeamRepos::delByTeamId($gt->id); } } if ($haveEleme) { $user = $client->request('user'); $email = isset($user->email) ? $user->email : ''; $cookie = GithubLogin::login($user->login, $email, $accessToken, $orgTeams); return Redirect::to('/')->withCookie($cookie); } else {