Example #1
0
 public function actionAutomatic($hash, Application $app)
 {
     // Find project from hash
     $project = Project::where('hash', '=', $hash)->first();
     // Check that project exists
     if (is_null($project)) {
         $app->abort(404, 'Project not found');
     }
     // Check that project is set to be automatically triggered to deploy
     if (!$project->isTriggeredAutomatically()) {
         $app->abort(404, 'Project not set to allow automatic deployment');
     }
     // Create host object
     $projectHostClass = 'Deployer\\Host\\' . $project->host;
     $host = new $projectHostClass($app['request']);
     // Check pushed branch is the branch that the project deploys from
     $branch = $host->getBranch();
     if ($project->branch != $branch) {
         $app->abort(404, 'Pushed branch is not set to trigger deployment');
     }
     // Check the pusher is a user
     $pusher = $host->getPusher();
     $username = Username::where('host', '=', $project->host)->where('username', '=', $pusher)->first();
     if (is_null($username)) {
         $app->abort(404, 'Unknown pusher');
     }
     $user = $username->user;
     // OK, all looks good, let's attempt a deployment
     $deployment = new Deployment();
     $deployment->isBeingTriggeredAutomatically();
     if (!$deployment->process($project, $user, $app)) {
         $app->abort(500, 'Deployment failed');
     }
     return 'Deployment successful';
 }
Example #2
0
 public function actionProcessDelete(Project $project, Application $app)
 {
     $project->delete();
     return $app->redirect('project.list', array('successMessage' => 'Project successfully deleted'));
 }
Example #3
0
 public function actionProcessLogout(Application $app)
 {
     $app['sentry']->logout();
     return $app->redirect('login', array('successMessage' => 'You have successfully logged out'));
 }