diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..08f7c34 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,83 @@ +# Node.js Function App to Linux on Azure +# Build a Node.js function app and deploy it to Azure as a Linux function app. +# Add steps that analyze code, save build artifacts, deploy, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript + +trigger: +- master + +variables: + + # Azure Resource Manager connection created during pipeline creation + azureSubscription: 'cd86fe07-a0e7-445d-a50b-47b75954bb78' + + # Function app name + functionAppName: 'time-tracker-azure-functions' + + # Environment name + environmentName: 'time-tracker-azure-functions' + + # Agent VM image name + vmImageName: 'ubuntu-latest' + +stages: +- stage: Build + displayName: Build stage + jobs: + - job: Build + displayName: Build + pool: + vmImage: $(vmImageName) + + steps: + - task: NodeTool@0 + inputs: + versionSpec: '10.x' + displayName: 'Install Node.js' + + - script: | + if [ -f extensions.csproj ] + then + dotnet build extensions.csproj --runtime ubuntu.16.04-x64 --output ./bin + fi + displayName: 'Build extensions' + + - script: | + npm install + npm run build --if-present + npm run test --if-present + displayName: 'Prepare binaries' + + - task: ArchiveFiles@2 + displayName: 'Archive files' + inputs: + rootFolderOrFile: '$(System.DefaultWorkingDirectory)' + includeRootFolder: false + archiveType: zip + archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip + replaceExistingArchive: true + + - upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip + artifact: drop + +- stage: Deploy + displayName: Deploy stage + dependsOn: Build + condition: succeeded() + jobs: + - deployment: Deploy + displayName: Deploy + environment: $(environmentName) + pool: + vmImage: $(vmImageName) + strategy: + runOnce: + deploy: + steps: + - task: AzureFunctionApp@1 + displayName: 'Azure Functions App Deploy: time-tracker-azure-functions' + inputs: + azureSubscription: '$(azureSubscription)' + appType: functionAppLinux + appName: $(functionAppName) + package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip' \ No newline at end of file