-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
164 lines (143 loc) · 4.67 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Node.js Express Web App to Linux on Azure
# Build a Node.js Express app and deploy it to Azure as a Linux web app.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
trigger:
- main
- azure_pipelines
variables:
# Azure Resource Manager connection created during pipeline creation
azureSubscription: '19c5bad8-bedd-4c8f-8c72-ead439f9a190'
# Web app name
webAppName: 'online-job-portal'
# Environment name
environmentName: prasaya
stages:
- stage: Build
displayName: Build frontend and backend'
pool: Pool
jobs:
- job: Install
displayName: Install dependencies
steps:
- checkout: self
clean: false
- script: yarn
displayName: Install backend dependencies
- script: yarn
displayName: Install frontend dependencies
workingDirectory: $(System.DefaultWorkingDirectory)/src/client
- job: Build
dependsOn: Install
displayName: Build frontend and backend
steps:
- checkout: none
- script: yarn build
displayName: Build frontend and backend
- stage: Deploy
displayName: Deploy stage
dependsOn: Build
condition: succeeded()
jobs:
- deployment: Deploy
displayName: Deploy application
pool: Pool
environment: $(environmentName)
strategy:
runOnce:
deploy:
steps:
- script: |
pm2 describe WebApp > /dev/null
RUNNING=$?
if [ "${RUNNING}" -ne 0 ]; then
pm2 start dist/backend.cjs --name WebApp
else
pm2 reload WebApp
fi;
displayName: 'Run express application'
workingDirectory: '$(System.DefaultWorkingDirectory)'
# - stage: Build_frontend
# displayName: Build Frontend
# pool:
# vmImage: 'ubuntu-latest'
# jobs:
# - job: Build_frontend
# displayName: Build React App
# steps:
# - checkout: self
# - script: yarn
# displayName: Install required frontend dependencies
# workingDirectory: $(System.DefaultWorkingDirectory)/src/client
# - script: yarn
# displayName: Install required build dependencies
# workingDirectory: $(System.DefaultWorkingDirectory)
# - script: NODE_ENV=production yarn client
# displayName: Build React App
# workingDirectory: $(System.DefaultWorkingDirectory)
# - task: CopyFiles@2
# displayName: 'Copy required files'
# inputs:
# SourceFolder: '$(System.DefaultWorkingDirectory)'
# Contents: |
# dist/public/**
# TargetFolder: '$(Build.ArtifactStagingDirectory)'
# - publish: '$(Build.ArtifactStagingDirectory)'
# displayName: 'Publish build artifacts'
# artifact: Frontend
# - stage: Build_backend
# displayName: Build and Test stage
# pool: Pool
# jobs:
# - job: Build
# displayName: Build Backend
# steps:
# - checkout: self
# clean: false
# - script: |
# yarn
# displayName: 'yarn install dependencies for backend'
# workingDirectory: $(System.DefaultWorkingDirectory)
# - script: yarn buildServer
# displayName: 'yarn build for backend'
# workingDirectory: $(System.DefaultWorkingDirectory)
# - job: Test
# displayName: Test code
# dependsOn: Build
# pool: Pool
# steps:
# - checkout: none
# - script: |
# yarn test
# displayName: 'yarn test for backend'
# workingDirectory: $(System.DefaultWorkingDirectory)
# - stage: Deploy
# displayName: Deploy stage
# dependsOn: [Build_backend, Build_frontend]
# condition: succeeded()
# jobs:
# - deployment: Deploy
# displayName: Deploy application
# pool: Pool
# environment: $(environmentName)
# strategy:
# runOnce:
# deploy:
# steps:
# - download: current
# artifact: Frontend
# - task: CopyFiles@2
# displayName: 'Copy required files'
# inputs:
# SourceFolder: '$(Pipeline.Workspace)/Frontend/'
# TargetFolder: '$(System.DefaultWorkingDirectory)'
# - script: |
# pm2 describe WebApp > /dev/null
# RUNNING=$?
# if [ "${RUNNING}" -ne 0 ]; then
# pm2 start dist/backend.cjs --name WebApp
# else
# pm2 reload WebApp
# fi;
# displayName: 'Run express application'
# workingDirectory: '$(System.DefaultWorkingDirectory)'