forked from pnp/sp-dev-solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.ps1
50 lines (36 loc) · 1.21 KB
/
deploy.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
[CmdletBinding()]
Param (
[Parameter(Mandatory = $False)]
[switch]$OverwriteSettings,
[Parameter(Mandatory = $False)]
[switch]$Minified
)
$0 = $myInvocation.MyCommand.Definition
$CommandDirectory = [System.IO.Path]::GetDirectoryName($0)
$AppSettingsFilePath = Join-Path -Path $CommandDirectory -ChildPath "src\local.settings.json"
$AppSettings = Get-Content -Path $AppSettingsFilePath -Raw | ConvertFrom-Json
$ErrorActionPreference = 'Continue'
# Execute tests
npm run test:ci 2>&1 | Write-Host
if ($LASTEXITCODE -eq 1) {
throw "Error during tests!"
}
# Build the solution
$ErrorActionPreference = 'Stop'
if ($Minified.IsPresent) {
npm run build
} else {
npm run build:dev
}
# Deploy the functions
Push-Location '.\dist'
# Get the Azure function name according to the settings
$AzureFunctionName = $AppSettings.Values.Azure_Function_Name
Write-Output "Deploy to function $AzureFunctionName..."
if ($OverwriteSettings.IsPresent) {
# https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local#publish
func azure functionapp publish $AzureFunctionName --publish-local-settings --overwrite-settings
} else {
func azure functionapp publish $AzureFunctionName
}
Pop-Location