/** * @param CreateRelease $request * @return Release */ public function create(CreateRelease $request) { $repo = $request->repo(); $commit = $repo->git()->getCommit($request->get('commit')); if (!$commit) { abort(404); } $release = Release::create(['repo_id' => $repo->id, 'commit' => $commit->getHash(), 'status' => Release::QUEUED, 'roles' => $request->roles(), 'inventory_id' => $request->get('inventory_id'), 'user_id' => $this->user()->id]); $this->dispatch(new PrepareReleaseJob($release)); return $release; }
public function fire(Dispatcher $bus) { $repo = $this->loadRepo(); $inv = $this->loadInventory($repo); $commit = $this->getCommit($repo); $release = Release::create(['repo_id' => $repo->id, 'commit' => $commit->getHash(), 'status' => Release::QUEUED, 'roles' => ["dogpro.deploy"], 'inventory_id' => $inv->id, 'user_id' => 1, 'params' => []]); $this->output->getFormatter()->setDecorated(true); $release->logger()->setOutput($this->output); try { $bus->dispatchNow(new PrepareReleaseJob($release, true)); } catch (\Exception $e) { $this->output->writeln($e->getMessage()); } }
public function checkCommitsForDeployTags() { $inv = null; $commit = null; foreach ($this->commitList as $commit) { $parts = explode(" ", $commit['message']); if (($index = array_search('@deploy', $parts)) !== false) { if (isset($parts[$index + 1])) { $inv = $this->repo->inventories()->where('name', trim($parts[$index + 1]))->get()->first(); if ($inv) { break; } } } } if ($inv instanceof Inventory && !empty($commit['hash'])) { $this->dispatch(new PrepareReleaseJob(Release::create(['repo_id' => $this->repo->id, 'commit' => $commit['hash'], 'status' => Release::QUEUED, 'roles' => ['dogpro.deploy'], 'inventory_id' => $inv->id]))); } }