Route::post('/playload', function () { if (Request::header('X-GitHub-Event') == 'pull_request') { $content = file_get_contents('php://input'); $notifyObject = json_decode($content); $repoFullName = $notifyObject->pull_request->base->repo->full_name; $siteId = WebSite::getSiteIdByFullName($repoFullName); $commit = $notifyObject->pull_request->head->sha; $pullNumber = $notifyObject->pull_request->number; if ($siteId !== NULL) { $pr = new PullRequest($siteId); $have = $pr->get($commit); if ($have !== NULL) { if ($notifyObject->action == 'closed') { $mgb = $notifyObject->pull_request->merged_by; $have->mergedBy = empty($mgb) ? '' : $mgb->login; $commitList = $pr->getListByPRId($notifyObject->pull_request->id); foreach ($commitList as $m) { $m->status = 'closed'; $pr->save($m); } } elseif ($notifyObject->action == 'reopened') { $commitList = $pr->getListByPRId($notifyObject->pull_request->id); foreach ($commitList as $m) { $m->status = 'open'; $pr->save($m); } } $have->status = $notifyObject->pull_request->state; $pr->save($have); } else { //Queue::push('PullRequestBuild', array('siteId' => $siteId, 'commit' => $commit), DeployInfo::PR_BUILD_QUEUE);