Skip to content

Commit f796534

Browse files
committed
Add deploy script to do deployments after the initial creation of pipeline
1 parent ee6e12e commit f796534

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

DeployToPipeline.ps1

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
if ((Get-AWSCredentials) -eq $null)
2+
{
3+
throw "You must set credentials via Set-AWSCredentials before running this cmdlet."
4+
}
5+
if ((Get-DefaultAWSRegion) -eq $null)
6+
{
7+
throw "You must set a region via Set-DefaultAWSRegion before running this cmdlet."
8+
}
9+
10+
function _deployRepository()
11+
{
12+
$pipelineSourceConfig = (Get-CPPipeline ExploringAspNetCore-Part2).Stages[0].Actions[0].Configuration
13+
$bucketName = $pipelineSourceConfig["S3Bucket"]
14+
$s3Key = $pipelineSourceConfig["S3ObjectKey"]
15+
16+
Write-Host 'Zipping Repository'
17+
Add-Type -assembly "system.io.compression.filesystem"
18+
$destination = [System.io.Path]::Combine([System.io.Path]::GetTempPath(), 'aws-blog-net-exploring-aspnet-core.zip')
19+
If (Test-Path $destination)
20+
{
21+
Remove-Item $destination
22+
}
23+
24+
Write-Host 'Zipping up repository for initial deployment in pipeline'
25+
[io.compression.zipfile]::CreateFromDirectory($PSScriptRoot, $destination)
26+
27+
Write-Host 'Writing zip to S3 ' $bucketName
28+
Write-S3Object -BucketName $bucketName -File $destination -Key $s3Key
29+
30+
$bucketName
31+
}
32+
33+
34+
_deployRepository

0 commit comments

Comments
 (0)