Created
October 1, 2018 16:37
-
-
Save forki/d09a125c95fec8c4d5d2065248e85716 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let getFunctionApp projectName = | |
match projectName with | |
| "RenderInvoice.fsproj" -> | |
"" | |
| "TransactionHandling.fsproj" -> | |
"ecartransactions" | |
| "OCPPStatus.fsproj" -> | |
"ocppstatus" | |
| "Accounting.fsproj" -> | |
"ecaraccounting" | |
| "ChargingPointCache.fsproj" -> | |
"ecarcache" | |
| "ChargingPointImport.fsproj" -> | |
"chargingpointimport" | |
| "UserManagement.fsproj" -> | |
"ecarusermanagement" | |
| "BraintreePayment.fsproj" -> | |
"ecarpayment" | |
| "Reservation.fsproj" -> | |
"ecarreservation" | |
| "Roaming.fsproj" -> | |
"ecarroaming-dev" | |
| _ -> | |
"ecarjobs" | |
let azureFunctionsfilter = getBuildParamOrDefault "FunctionApp" "" | |
let functionApps = | |
["ecartransactions"; "ocppstatus"; "ecarjobs"; "ecaraccounting"; "ecarcache"; "chargingpointimport"; | |
"ecarusermanagement"; "ecarpayment"; "ecarreservation"; "ecarroaming-dev" ] | |
Target "PublishAzureFunctions" (fun _ -> | |
let deployDir = deployDir + "/functions" | |
CleanDir deployDir | |
for functionApp in functionApps do | |
if azureFunctionsfilter <> "" && functionApp <> azureFunctionsfilter then () else | |
let deployDir = deployDir + "/" + functionApp | |
CleanDir deployDir | |
!! (functionsPath + "/*.json") | |
|> CopyFiles deployDir | |
let functionsToDeploy = | |
!! (functionsPath + "/**/*.fsproj") | |
|> Seq.filter (fun proj -> | |
let fi = FileInfo proj | |
getFunctionApp fi.Name = functionApp) | |
|> Seq.toList | |
let targetBinDir = deployDir + "/bin" | |
CleanDir targetBinDir | |
functionsToDeploy | |
|> Seq.iter (fun proj -> | |
let fi = FileInfo proj | |
runDotnet fi.Directory.FullName (sprintf "publish -c Release %s" fi.Name) | |
let targetPath = deployDir + "/" + fi.Name.Replace(fi.Extension,"") + "/" | |
CleanDir targetPath | |
tracefn " Target: %s" targetPath | |
let mutable found = false | |
let allFiles x = found <- true; allFiles x | |
let publishDir = Path.Combine(fi.Directory.FullName,"bin/Release/netstandard2.0/publish") | |
let binDir = Path.Combine(publishDir,"bin") | |
if Directory.Exists binDir then | |
CopyDir targetBinDir binDir allFiles | |
!! (publishDir + "/*.deps.json") | |
|> CopyFiles targetBinDir | |
else | |
CopyDir targetBinDir publishDir allFiles | |
let functionJson = publishDir + "/**/function.json" | |
!! functionJson | |
|> Seq.iter (fun fileName -> | |
let fi = FileInfo fileName | |
let target = Path.Combine(targetPath,"..",fi.Directory.Name) | |
CleanDir target | |
fileName |> CopyFile target) | |
if fi.Name.StartsWith "Roaming" then | |
!! "./documents/Hubject/Certs_MSU/*.*" | |
|> CopyFiles targetBinDir | |
if not found then failwithf "No files found for function %s" fi.Name | |
!! (fi.Directory.FullName + "/function.json") | |
|> CopyFiles targetPath | |
) | |
runFunc deployDir ("azure functionapp publish " + functionApp) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment