-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathazure-pipelines.yml
124 lines (119 loc) · 3.72 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
trigger:
batch: true
branches:
include:
- main
- feature/*
- fix/*
exclude:
- releases/*
variables:
- name: webAppName
value: 'lab-gen-demo'
- name: resourceGroupName
value: 'lab-gen-website'
- name: tag
value: '$(Build.BuildId)'
- name: zipFile
value: 'next-$(Build.BuildId).zip'
- name: isMain
value: $[eq(variables['Build.SourceBranch'], 'refs/heads/main')]
- name: 'System.Debug'
value: true
- name: slot
${{ if eq(variables['Build.SourceBranch'], 'refs/heads/main') }}:
value: 'dev'
${{ if ne(variables['Build.SourceBranch'], 'refs/heads/main') }}:
value: 'build'
- name: vmImageName
value: 'ubuntu-latest'
pool:
vmImage: $(vmImageName)
stages:
- stage: Build
displayName: Build and deploy project
jobs:
- job: 'LabGenerativeDemo'
displayName: 'Build Tech Lab Generative'
steps:
- task: UseNode@1
inputs:
version: '18.x'
displayName: 'Install Node.js'
- script: |
echo "Slot is $(slot), tag is $(tag) and isMain is $(isMain)"
displayName: 'Echo variables'
- script: |
npm ci
displayName: 'npm install'
- script: |
npm run lint
displayName: 'Run ESLint'
- script: |
npm test
displayName: 'npm test'
- script: |
npm run build-ci
displayName: 'npm build'
- script: |
zip -r $(zipFile) .next/* package.json package-lock.json
displayName: 'Zip up files'
- publish: $(zipFile)
displayName: 'Upload package'
artifact: next
- stage: Deploy
displayName: Deploy the app
dependsOn: Build
condition: succeeded()
jobs:
- deployment: 'LabGenDeploy'
displayName: 'Deploy to Azure'
environment: 'web-$(slot)'
strategy:
runOnce:
deploy:
steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'next'
targetPath: '$(Pipeline.Workspace)/bin'
- task: AzureRmWebAppDeployment@4
displayName: Deploy the Web App
inputs:
ConnectionType: 'AzureRM'
appType: 'webAppLinux'
deployToSlotOrASE: true
SlotName: '$(slot)'
azureSubscription: $(azureSubscription)
WebAppName: $(webAppName)
ResourceGroupName: $(resourceGroupName)
Package: '$(Pipeline.Workspace)/bin/$(zipFile)'
- stage: ProdDeploy
displayName: Deploy to production
dependsOn: Deploy
condition: and(succeeded(), eq(variables.isMain, true))
jobs:
- deployment: BuildPackPublish
displayName: Production
environment: web-production
strategy:
runOnce:
deploy:
steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'next'
targetPath: '$(Pipeline.Workspace)/bin'
- task: AzureRmWebAppDeployment@4
displayName: Deploy to the production Web App
inputs:
ConnectionType: "AzureRM"
appType: "webAppLinux"
deployToSlotOrASE: true
azureSubscription: $(azureSubscription)
WebAppName: $(webAppName)
ResourceGroupName: $(resourceGroupName)
SlotName: production
Package: '$(Pipeline.Workspace)/bin/$(zipFile)'