-
Notifications
You must be signed in to change notification settings - Fork 465
/
deploy.heroku.ps1
60 lines (49 loc) · 1.06 KB
/
deploy.heroku.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
$location = Get-Location | Select-Object $_.Path
$packOutput = Join-Path $location "bin\Release\netcoreapp2.0\publish"
$appName = "aspnetcorespa"
function DeletePublishFolder()
{
if (Test-Path $packOutput)
{
WriteInfo "Removing publish folder..."
Remove-Item -Force -Recurse $packOutput
}
}
function Publish()
{
dotnet publish -c Release
WriteSuccess "Published!"
}
function Deploy()
{
# Build image
& docker build -t $appName $packOutput
# Login heroku container service
& heroku container:login
# Tag image to be deployed
& docker tag $appName registry.heroku.com/$appName/web
# Deploy to heroku container
& docker push registry.heroku.com/$appName/web
if ($LASTEXITCODE -ne 0)
{
WriteFailed "Failed with code $LASTEXITCODE. Exiting..."
Exit
}
WriteSuccess "Deployment succeeded!"
}
function WriteFailed($text)
{
Write-Host $text -ForegroundColor Red
}
function WriteInfo($text)
{
Write-Host $text -ForegroundColor Cyan
}
function WriteSuccess($text)
{
Write-Host $text -ForegroundColor Green
}
# -----------
DeletePublishFolder
Publish
Deploy