REBELinBLUE\Deployer\Contracts\Repositories\DeploymentRepositoryInterface::getLatestSuccessful PHP 메소드

getLatestSuccessful() 공개 메소드

public getLatestSuccessful ( integer $project_id ) : Deployment
$project_id integer
리턴 REBELinBLUE\Deployer\Deployment
    public function getLatestSuccessful($project_id);

Usage Example

예제 #1
0
 /**
  * Takes the data returned from the webhook request and then adds deployers own data, such as project ID
  * and runs any checks such as checks the branch is allowed to be deployed.
  *
  * @param array $payload
  * @param Request $request
  * @param Project $project
  *
  * @return array|false Either an array of the complete deployment config, or false if it is invalid.
  */
 private function appendProjectSettings($payload, Request $request, Project $project)
 {
     // If the payload is empty return false
     if (!is_array($payload) || !count($payload)) {
         return false;
     }
     $payload['project_id'] = $project->id;
     // If there is no branch set get it from the project
     if (is_null($payload['branch']) || empty($payload['branch'])) {
         $payload['branch'] = $project->branch;
     }
     // If the project doesn't allow other branches check the requested branch is the correct one
     if (!$project->allow_other_branch && $payload['branch'] !== $project->branch) {
         return false;
     }
     $payload['optional'] = [];
     // Check if the commands input is set, if so explode on comma and filter out any invalid commands
     if ($request->has('commands')) {
         $valid = $project->commands->lists('id');
         $requested = explode(',', $request->get('commands'));
         $payload['optional'] = collect($requested)->unique()->intersect($valid)->toArray();
     }
     // If the webhook is allowed to deploy other branches check if the request has an update_only
     // query string and if so check the branch matches that which is currently deployed
     if ($project->allow_other_branch && $request->has('update_only') && $request->get('update_only') !== false) {
         $deployment = $this->deploymentRepository->getLatestSuccessful($project->id);
         if (!$deployment || $deployment->branch !== $payload['branch']) {
             return false;
         }
     }
     return $payload;
 }