-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathazure-pipelines.yml
99 lines (95 loc) · 4.83 KB
/
azure-pipelines.yml
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
trigger:
- main
pr:
- main
pool:
vmImage: "Ubuntu-20.04"
variables:
dockerImage: workerimage
steps:
- task: NodeTool@0
inputs:
versionSpec: "12.x"
displayName: "Install Node.js"
- script: |
cd packages/utils
npm install --ignore-engines
yarn build
echo "Removing node_modules to avoid issues building the whole project"
rm -rf node_modules
displayName: "Build utils"
- script: |
yarn --ignore-engines
yarn test
displayName: "yarn and yarn test"
- script: |
npm install -g azure-functions-core-tools
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
displayName: "Install Azure functions core tools"
- script: |
./scripts/ci/install-extensions.sh
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
displayName: "Install Azure Function extensions"
- script: |
./scripts/ci/build-services-functions.sh
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
displayName: "Install dependecies for utils and services functions"
- task: ArchiveFiles@2
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
inputs:
rootFolderOrFile: "$(Build.SourcesDirectory)/packages/services"
includeRootFolder: false
archiveType: "zip"
archiveFile: "$(Build.ArtifactStagingDirectory)/services/$(Build.BuildId).zip"
replaceExistingArchive: true
verbose: true
displayName: Create deployment zip file for service functions
- task: Docker@2
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
displayName: Login to ACR (Production)
inputs:
command: login
containerRegistry: DockerACRConnectionNew
- task: Docker@2
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
displayName: Login to ACR (Staging)
inputs:
command: login
containerRegistry: DockerACRConnectionStaging
- task: Docker@2
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
displayName: Build and push worker image
inputs:
command: buildAndPush
repository: $(dockerImage)
tags: $(Build.BuildId)
Dockerfile: $(Build.SourcesDirectory)/packages/worker/Dockerfile
buildContext: $(Build.SourcesDirectory)
- task: AzureFunctionApp@1
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
inputs:
azureSubscription: "webhint-staging"
appType: "functionAppLinux"
appName: "service-functions-staging"
package: "$(Build.ArtifactStagingDirectory)/services/$(Build.BuildId).zip"
runtimeStack: "DOCKER|microsoft/azure-functions-node8:2.0"
appSettings: "-APP_INSIGHTS_KEY $(APPINSIGHTS_INSTRUMENTATIONKEY) -APPINSIGHTS_INSTRUMENTATIONKEY $(APPINSIGHTS_INSTRUMENTATIONKEY) -AzureWebJobsStorage $(AzureWebJobsStorage) -DatabaseConnection $(DatabaseConnection) -QueueConnection $(QueueConnection) -FUNCTIONS_EXTENSION_VERSION $(FUNCTIONS_EXTENSION_VERSION) -FUNCTIONS_WORKER_RUNTIME $(FUNCTIONS_WORKER_RUNTIME) -WEBSITE_ENABLE_SYNC_UPDATE_SITE $(WEBSITE_ENABLE_SYNC_UPDATE_SITE) -WEBSITE_NODE_DEFAULT_VERSION $(WEBSITE_NODE_DEFAULT_VERSION) -WEBSITES_ENABLE_APP_SERVICE_STORAGE $(WEBSITES_ENABLE_APP_SERVICE_STORAGE) -WEBSITE_RUN_FROM_PACKAGE $(WEBSITE_RUN_FROM_PACKAGE)"
displayName: Deploy service functions
- task: AzureFunctionAppContainer@1
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
displayName: Deploy worker function
inputs:
azureSubscription: "webhint-staging"
appName: worker-functions-staging
imageName: $(DOCKER_REPOSITORY)/$(dockerImage):$(Build.BuildId)
appSettings: "-APP_INSIGHTS_KEY $(APPINSIGHTS_INSTRUMENTATIONKEY) -APPINSIGHTS_INSTRUMENTATIONKEY $(APPINSIGHTS_INSTRUMENTATIONKEY) -AzureWebJobsStorage $(AzureWebJobsStorage) -QueueConnection $(QueueConnection) -FUNCTIONS_EXTENSION_VERSION $(FUNCTIONS_EXTENSION_VERSION) -FUNCTIONS_WORKER_RUNTIME $(FUNCTIONS_WORKER_RUNTIME) -WEBSITE_NODE_DEFAULT_VERSION $(WEBSITE_NODE_DEFAULT_VERSION)"
- task: PublishBuildArtifacts@1
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)/services'
ArtifactName: 'services'
publishLocation: 'Container'