-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
59 lines (52 loc) · 1.57 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
trigger:
- main
- develop
resources:
- repo: self
variables:
dockerRegistryServiceConnection: 'ac26bf70-aaa8-46a8-b651-e5b7c382ec69'
imageRepository: 'set-azure-project'
dockerfilePath: '$(Build.SourcesDirectory)/Dockerfile'
${{ if eq(variables['Build.SourceBranchName'], 'main') }}:
tag: 'latest'
${{ if eq(variables['Build.SourceBranchName'], 'develop') }}:
tag: 'dev'
stages:
- stage: buildApp
displayName: 'build app'
jobs:
- job: buildAppJob
displayName: 'build app'
pool:
vmImage: ubuntu-latest
steps:
- task: NodeTool@0
inputs:
versionSpec: '18.x'
displayName: 'install node.js'
- script: |
yarn install
yarn build
displayName: 'yarn install and build'
- script: yarn lint-run
displayName: 'eslint code analysis'
- script: yarn test
displayName: 'run unit tests using jest'
- stage: buildImage
dependsOn: buildApp
displayName: 'build and push docker image'
jobs:
- job: buildImageJob
displayName: 'build and push docker image'
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Docker@2
displayName: 'build and push an image to azure container registry'
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)