-
Notifications
You must be signed in to change notification settings - Fork 69
/
before_build.ps1
24 lines (16 loc) · 1.16 KB
/
before_build.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
Write-Host "Setting up appsettings.json for tests"
$strConfigSource = "$env:APPVEYOR_BUILD_FOLDER\CloudinaryDotNet.IntegrationTests\appsettings.json.sample"
$strConfigDest = "$env:APPVEYOR_BUILD_FOLDER\CloudinaryDotNet.IntegrationTests\appsettings.json"
$apiEndpoint = "https://sub-account-testing.cloudinary.com/create_sub_account"
$postParams = @{
"prefix"="DotNet"
} | ConvertTo-Json
$res = Invoke-WebRequest -Uri $apiEndpoint -ContentType "application/json" -Method POST -Body $postParams | ConvertFrom-Json
$cloud = $res.payload
Copy-Item $strConfigSource -Destination $strConfigDest
(Get-Content $strConfigDest).replace('"ApiBaseAddress": ""', '"ApiBaseAddress": "' + $env:ApiBaseAddress + '"') | Set-Content $strConfigDest
(Get-Content $strConfigDest).replace('"CloudName": ""', '"CloudName": "' + $cloud.cloudName + '"') | Set-Content $strConfigDest
(Get-Content $strConfigDest).replace('"ApiKey": ""', '"ApiKey": "'+ $cloud.cloudApiKey + '"') | Set-Content $strConfigDest
(Get-Content $strConfigDest).replace('"ApiSecret": ""', '"ApiSecret": "' + $cloud.cloudApiSecret + '"') | Set-Content $strConfigDest
Write-Host "CloudName: $($cloud.cloudName)"
Write-Host "Done"