-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
83 lines (72 loc) · 2.38 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
# 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
- release/*
- production/*
pr:
- main
pool:
vmImage: ubuntu-latest
variables:
# pipeline conditions
isMain: ${{ eq(variables['Build.SourceBranch'], 'refs/heads/main') }}
isRelease: ${{ startsWith(variables['Build.SourceBranch'], 'refs/heads/release') }}
isProduction: ${{ startsWith(variables['Build.SourceBranch'], 'refs/heads/production') }}
# build information
ACR.Name: 'projectdemo'
ACR.ImageName: '$(ACR.Name):$(Build.BuildId)'
ACR.FullName: '$(ACR.Name).azurecr.io'
ACR.RepoName: 'projectdemodeploy'
stages:
- stage: Test
displayName: Test stage
# don't need condition check here, as pipeline only is invoked in pr to main,
# and changes to main, release and production branch
# condition: or(eq(variables.isMain, 'True'), eq(variables.isRelease, 'True'), eq(variables.isProduction, 'True'))
jobs:
- job: Test
steps:
- task: NodeTool@0
inputs:
versionSource: 'spec'
versionSpec: '16.19.x'
- script: |
yarn install
yarn test
displayName: 'yarn install && test'
- stage: BuildApp
displayName: build and push stage
condition: or(eq(variables.isMain, 'True'), eq(variables.isRelease, 'True'), eq(variables.isProduction, 'True'))
jobs:
- job: BuildPushImage
steps:
- task: Docker@2
inputs:
containerRegistry: 'demo-azure-registry-connection1'
repository: '$(ACR.RepoName)'
command: 'build'
Dockerfile: '**/Dockerfile'
- task: Docker@2
inputs:
containerRegistry: 'demo-azure-registry-connection1'
repository: '$(ACR.RepoName)'
command: 'push'
- stage: DevDeploy
displayName: deploy development
condition: eq(variables.isRelease, 'True')
jobs:
- job: Deploy
steps:
- task: AzureRmWebAppDeployment@4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'NIH-Awd.OSU.NICHD.BMICloudComputing (336bf15c-53ea-4b44-9489-ca22bafe881b)'
appType: 'webAppContainer'
WebAppName: 'projdemo'
DockerNamespace: '$(ACR.FullName)'
DockerRepository: '$(ACR.RepoName)'
DockerImageTag: '$(Build.BuildId)'
StartupCommand: 'yarn start'