public function indexAction(Request $request) { $webhook_payload = $request->request->get('payload'); if (!empty($webhook_payload)) { $payload_params = json_decode($webhook_payload, true); $head_commit_id = $payload_params['head_commit']['id']; $logger = $this->get('logger'); $logger->error(print_r($head_commit_id, true)); $CodeDeployClient = new CodeDeployClient(['version' => 'latest', 'region' => 'us-east-1']); $DeploymentResult = $CodeDeployClient->createDeployment(['applicationName' => 'ttapp', 'deploymentGroupName' => 'ttapp_dg', 'revision' => ['revisionType' => 'GitHub', 'gitHubLocation' => ['repository' => 'kxr/ttapp', 'commitId' => "{$head_commit_id}"]]]); $logger->error(print_r($DeploymentResult, true)); } //TODO If /setup is visited normally, it would be nice //to display the status of last deployment(s) return new Response('This is a webhook for github'); }
public function do() { $this->io->writeln('Deploying via Codedeploy!'); $s3Client = new S3Client(['version' => 'latest', 'region' => 'us-east-1']); $adapter = new AwsS3Adapter($s3Client, $this->config->get('bucket')); $s3 = new Filesystem($adapter); $build_file = $this->config->get('build_path', getcwd() . '/build') . '/build.zip'; if (!file_exists($build_file)) { throw new \Exception('Could not find build file.'); } $stream = fopen($build_file, 'r+'); $fileMd5 = md5_file($build_file); $s3File = $this->config->get('AppName') . '/revisions/' . $fileMd5 . '.zip'; $s3->writeStream($s3File, $stream); $codedeploy = new CodeDeployClient(['region' => 'us-east-1', 'version' => 'latest']); $codedeploy->registerApplicationRevision(['applicationName' => $this->config->get('AppName'), 'revision' => ['revisionType' => 'S3', 's3Location' => ['bucket' => $this->config->get('bucket'), 'key' => $s3File, 'bundleType' => 'zip']]]); $codedeploy->createDeployment(['applicationName' => $this->config->get('AppName'), 'deploymentGroupName' => $this->config->get('AppName'), 'revision' => ['revisionType' => 'S3', 's3Location' => ['bucket' => $this->config->get('bucket'), 'key' => $s3File, 'bundleType' => 'zip']], 'ignoreApplicationStopFailures' => false]); }