Пример #1
0
 /**
  * Display a listing of before/after commands for the supplied stage.
  *
  * @param int $target_id
  * @param int $action
  *
  * @return \Illuminate\View\View
  */
 public function listing($target_id, $action)
 {
     $types = ['clone' => Command::DO_CLONE, 'install' => Command::DO_INSTALL, 'activate' => Command::DO_ACTIVATE, 'purge' => Command::DO_PURGE];
     $project = $this->projectRepository->getById($target_id);
     $target = 'project';
     $breadcrumb = [['url' => route('projects', ['id' => $project->id]), 'label' => $project->name]];
     return view('commands.listing', ['breadcrumb' => $breadcrumb, 'title' => Lang::get('commands.' . strtolower($action)), 'subtitle' => $project->name, 'project' => $project, 'target_type' => $target, 'target_id' => $project->id, 'action' => $types[$action], 'commands' => $this->repository->getForDeployStep($project->id, $target, $types[$action])]);
 }
Пример #2
0
 /**
  * Generates a new webhook URL.
  *
  * @param int $project_id
  *
  * @return \Illuminate\View\View
  */
 public function refresh($project_id)
 {
     $project = $this->projectRepository->getById($project_id);
     $project->generateHash();
     $project->save();
     return ['url' => route('webhook.deploy', $project->hash)];
 }
Пример #3
0
 /**
  * Adds a deployment for the specified project to the queue.
  *
  * @param Request $request
  * @param int $project_id
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function deploy(Request $request, $project_id)
 {
     $project = $this->projectRepository->getById($project_id);
     if ($project->servers->where('deploy_code', true)->count() === 0) {
         return redirect()->route('projects', ['id' => $project->id]);
     }
     $data = ['reason' => $request->get('reason'), 'project_id' => $project->id, 'branch' => $project->branch, 'optional' => []];
     // If allow other branches is set, check for post data
     if ($project->allow_other_branch) {
         if ($request->has('source') && $request->has('source_' . $request->get('source'))) {
             $data['branch'] = $request->get('source_' . $request->get('source'));
         }
     }
     // Get the optional commands and typecast to integers
     if ($request->has('optional') && is_array($request->get('optional'))) {
         $data['optional'] = array_filter(array_map(function ($value) {
             return filter_var($value, FILTER_VALIDATE_INT);
         }, $request->get('optional')));
     }
     $deployment = $this->deploymentRepository->create($data);
     return redirect()->route('deployments', ['id' => $deployment->id]);
 }