-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
148 lines (138 loc) · 4.75 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
trigger:
branches:
include:
- develop
- staging
tags:
include:
- 'release-*'
name: $(SourceBranchName).$(Build.BuildId).$(Date:yyyyMMdd).$(Rev:r)
pool:
vmImage: 'ubuntu-22.04'
variables:
dockerRegistryServiceConnection: $(DOCKER_SERVICE_CONNECTION)
dockerfilePath: './Dockerfile'
app: $(DOCKER_REPOSITORY)
imageRepositoryDev: 'dev/$(app)'
imageRepositoryStg: 'stg/$(app)'
imageRepositoryProd: 'prod/$(app)'
tag: '$(Build.BuildId)'
steps:
# Unit Tests
- task: Bash@3
displayName: Unit Tests
condition: eq(variables['Build.SourceBranch'], 'refs/heads/develop')
continueOnError: true
inputs:
targetType: 'inline'
script: |
sudo yarn install
sudo yarn test-coverage
# Sonar Scan
- task: Bash@3
displayName: Sonar Scan
condition: eq(variables['Build.SourceBranch'], 'refs/heads/develop')
inputs:
targetType: 'inline'
script: |
export SONAR_SCANNER_VERSION=5.0.1.3006
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"
export SONAR_TOKEN=$(SONAR_TOKEN)
sonar-scanner \
-Dsonar.projectKey=${{ lower(variables['Build.DefinitionName']) }} \
-Dsonar.sources=src \
-Dsonar.host.url=$(SONAR_HOST) \
-Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info \
-Dsonar.exclusions=**/tests/**,**/test/**,**/lib/**
# Docker build and push
- task: Docker@2
displayName: Dev - Build image
inputs:
command: build
repository: $(imageRepositoryDev)
containerRegistry: $(dockerRegistryServiceConnection)
dockerfile: $(dockerfilePath)
arguments:
--build-arg=API_BASE_URL=$(API_BASE_URL_DEV)
--build-arg=API_MAPBOX_ACCESS_TOKEN=$(API_MAPBOX_ACCESS_TOKEN_DEV)
--build-arg=RECAPTCHA_KEY=$(RECAPTCHA_KEY_DEV)
--build-arg=B2C_CLIENT_ID=$(B2C_CLIENT_ID_DEV)
--build-arg=ENV=$(ENV_DEV)
--build-arg=MATOMO_SITE_ID=$(MATOMO_SITE_ID_DEV)
--build-arg=AIRTABLE_API_KEY=$(AIRTABLE_API_KEY)
tags: |
$(tag)
- task: Docker@2
displayName: Dev - Push image
inputs:
command: push
repository: $(imageRepositoryDev)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
- task: Docker@2
displayName: Stg - Build image
inputs:
command: build
repository: $(imageRepositoryStg)
containerRegistry: $(dockerRegistryServiceConnection)
dockerfile: $(dockerfilePath)
arguments:
--build-arg=API_BASE_URL=$(API_BASE_URL_STG)
--build-arg=API_MAPBOX_ACCESS_TOKEN=$(API_MAPBOX_ACCESS_TOKEN_STG)
--build-arg=RECAPTCHA_KEY=$(RECAPTCHA_KEY_STG)
--build-arg=B2C_CLIENT_ID=$(B2C_CLIENT_ID_STG)
--build-arg=ENV=$(ENV_STG)
--build-arg=MATOMO_SITE_ID=$(MATOMO_SITE_ID_STG)
--build-arg=AIRTABLE_API_KEY=$(AIRTABLE_API_KEY)
tags: |
$(tag)
condition:
and( succeeded(), eq(variables['Build.SourceBranch'],
'refs/heads/staging') )
- task: Docker@2
displayName: Stg - Push image
inputs:
command: push
repository: $(imageRepositoryStg)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
condition:
and( succeeded(), eq(variables['Build.SourceBranch'],
'refs/heads/staging') )
- task: Docker@2
displayName: Prod - Build image
inputs:
command: build
repository: $(imageRepositoryProd)
containerRegistry: $(dockerRegistryServiceConnection)
dockerfile: $(dockerfilePath)
arguments:
--build-arg=API_BASE_URL=$(API_BASE_URL_PROD)
--build-arg=API_MAPBOX_ACCESS_TOKEN=$(API_MAPBOX_ACCESS_TOKEN_PROD)
--build-arg=RECAPTCHA_KEY=$(RECAPTCHA_KEY_PROD)
--build-arg=B2C_CLIENT_ID=$(B2C_CLIENT_ID_PROD)
--build-arg=ENV=$(ENV_PROD)
--build-arg=MATOMO_SITE_ID=$(MATOMO_SITE_ID_PROD)
--build-arg=AIRTABLE_API_KEY=$(AIRTABLE_API_KEY)
tags: |
$(tag)
condition:
and( succeeded(), startsWith(variables['Build.SourceBranch'],
'refs/tags/release-') )
- task: Docker@2
displayName: Prod - Push image
inputs:
command: push
repository: $(imageRepositoryProd)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
condition:
and( succeeded(), startsWith(variables['Build.SourceBranch'],
'refs/tags/release-') )