forked from Azure/azure-functions-openapi-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.ps1
63 lines (46 loc) · 1.57 KB
/
entrypoint.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
61
62
63
Param(
[string]
[Parameter(Mandatory=$false)]
$FunctionAppPath = "bin/Debug/net6.0",
[string]
[Parameter(Mandatory=$false)]
$RequestUri = "http://localhost:7071/api/swagger.json",
[string]
[Parameter(Mandatory=$false)]
$DocumentPath = "generated",
[string]
[Parameter(Mandatory=$false)]
$DocumentName = "swagger.json",
[string]
[Parameter(Mandatory=$false)]
$Delay = "30",
[string]
[Parameter(Mandatory=$false)]
$IsRemote = "false"
)
$artifactPath = "$($env:GITHUB_WORKSPACE.TrimEnd('/'))/$($FunctionAppPath.Trim('/'))"
$generatedPath = "$($env:GITHUB_WORKSPACE.TrimEnd('/'))/$($DocumentPath.Trim('/'))"
$generatedFile = "$($DocumentPath.Trim('/'))/$($DocumentName)"
$outputPath = "$($env:GITHUB_WORKSPACE.TrimEnd('/'))/$generatedFile"
$remote = [System.Convert]::ToBoolean($IsRemote)
if ($remote -eq $false) {
pushd $artifactPath
Start-Process -NoNewWindow func @("start","--verbose","false")
if (($Delay -eq "") -or ($Delay -eq $null)) {
$Delay = "10"
}
$sleep = [System.Convert]::ToInt32($Delay)
if ($sleep -gt 0) {
Start-Sleep -Seconds $sleep
}
Remove-Variable -Name sleep
popd
}
mkdir $generatedPath
Invoke-RestMethod -Method Get -uri $requestUri | ConvertTo-Json -Depth 100 -Compress | Out-File $outputPath -Encoding utf8 -Force
Write-Output "::set-output name=generated::$generatedFile"
Remove-Variable -Name artifactPath
Remove-Variable -Name generatedPath
Remove-Variable -Name generatedFile
Remove-Variable -Name outputPath
Remove-Variable -Name remote