Skip to content

Instantly share code, notes, and snippets.

@forki
Created September 24, 2018 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save forki/a6de00427eb643a78264bf06ba625dfc to your computer and use it in GitHub Desktop.
Save forki/a6de00427eb643a78264bf06ba625dfc to your computer and use it in GitHub Desktop.
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