static void GetDeploymentStatus(string deploymentId, string region = "") { GetDeploymentResponse response = CodeDeployUtil.GetDeployment(deploymentId, region); if (response != null) { Log.Information("{0} {1} - CompleteTime: {2}", deploymentId, response.DeploymentInfo.Status, response.DeploymentInfo.CompleteTime); } }
static void Deploy(string application, string deploymentGroup, string s3Location, string appPath, string region) { try { if (!IsDotnetDirectory()) { Log.Warning("No .NET project found in directory {0}", Directory.GetCurrentDirectory()); return; } Match match = Regex.Match(s3Location, "(s3://)(.*)/([a-zA-Z-1-9\\.]*)$"); if (!match.Success) { Log.Error("Invalid S3 Location: {0}. Expected s3://<bucket-name>/<key>", s3Location); return; } string bucketName = $"{match.Groups[2].Value}"; string key = match.Groups[3].Value; string path = string.IsNullOrEmpty(appPath) ? "./" : appPath; Log.Information("Zipping app-path {0}", path); FileInfo zipFile = ArchiveUtil.CreateZip(path); FileStream zipFileStream = zipFile.Open(FileMode.Open); if (zipFileStream != null) { PutObjectResponse response = S3Util.UploadRevision(bucketName, key, zipFileStream); if (response != null) { string deploymentId = CodeDeployUtil.Deploy(application, deploymentGroup, bucketName, key, response.ETag.Replace("\"", ""), response.VersionId, region); zipFileStream.Close(); zipFile.Delete(); } } } catch (System.Exception e) { Log.Error($"{e.GetBaseException().GetType().Name}: {e.Message}"); } // Optional: Redirect to AWS Console/Get Deployment Details }