Skip to content

Commit 0040df1

Browse files
committed
Set up CI with Azure Pipelines for Asia server
[skip ci]
1 parent 0c77123 commit 0040df1

1 file changed

Lines changed: 137 additions & 0 deletions

File tree

azure-pipelines-asia.yml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Works
2+
trigger:
3+
- none
4+
5+
pool:
6+
vmImage: ubuntu-latest
7+
8+
stages:
9+
10+
- stage: Build_asia
11+
displayName: Build stage asia
12+
jobs:
13+
- job: Build_asia
14+
steps:
15+
16+
- task: DownloadSecureFile@1
17+
displayName: 'download ASIA backendend'
18+
inputs:
19+
secureFile: 'BACKEND_ENV_FILE_ASIA' # string. Required. Secure File.
20+
21+
- task: CopyFiles@2
22+
displayName: 'copy asia backendend'
23+
inputs:
24+
SourceFolder: '$(Agent.TempDirectory)'
25+
Contents: BACKEND_ENV_FILE_ASIA
26+
TargetFolder: './backend'
27+
28+
- script: mv ./backend/BACKEND_ENV_FILE_ASIA ./backend/.env
29+
displayName: 'rename asia .env'
30+
- task: DownloadSecureFile@1
31+
displayName: 'download asia frontend'
32+
inputs:
33+
secureFile: 'FRONTEND_ENV_FILE_ASIA' # string. Required. Secure File.
34+
35+
- task: CopyFiles@2
36+
displayName: 'copy asia frontend'
37+
inputs:
38+
SourceFolder: '$(Agent.TempDirectory)'
39+
Contents: FRONTEND_ENV_FILE_ASIA
40+
TargetFolder: './frontend'
41+
42+
- script: mv ./frontend/FRONTEND_ENV_FILE_ASIA ./frontend/.env
43+
displayName: 'rename asia .env'
44+
45+
- script: ls -a ./frontend
46+
displayName: 'ls'
47+
48+
- script: ls -Rn
49+
displayName: 'ls'
50+
51+
- task: NodeTool@0
52+
inputs:
53+
versionSpec: '12.20.1'
54+
displayName: 'Install Node.js'
55+
56+
- task: Bash@3
57+
inputs:
58+
targetType: 'inline'
59+
script: |
60+
node -v
61+
npm -v
62+
npm install
63+
npm run build
64+
65+
- task: ArchiveFiles@2
66+
displayName: 'Archive files'
67+
inputs:
68+
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
69+
includeRootFolder: false
70+
archiveType: zip
71+
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
72+
replaceExistingArchive: true
73+
- upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
74+
artifact: drop_asia
75+
76+
- deployment: VMDeploy_ASIA
77+
dependsOn: Build_asia
78+
displayName: DEPLOY ASIA
79+
environment:
80+
name: PROD
81+
resourceType: VirtualMachine
82+
tags: asia
83+
strategy:
84+
runOnce:
85+
preDeploy:
86+
steps:
87+
- task: DownloadPipelineArtifact@2
88+
inputs:
89+
buildType: 'current'
90+
artifactName: drop_asia
91+
targetPath: '$(Pipeline.Workspace)/drop'
92+
93+
- script: echo initialize, cleanup, backup, install certs
94+
95+
deploy:
96+
steps:
97+
- task: Bash@3
98+
inputs:
99+
targetType: 'inline'
100+
script: |
101+
# Modify deployment script based on the app type
102+
echo "Starting deployment script run"
103+
104+
105+
- task: ExtractFiles@1
106+
inputs:
107+
archiveFilePatterns: '$(Pipeline.Workspace)/drop_asia/$(Build.BuildId).zip'
108+
destinationFolder: '$(Pipeline.Workspace)/japp'
109+
cleanDestinationFolder: true
110+
overwriteExistingFiles: true
111+
112+
- task: DeleteFiles@1
113+
inputs:
114+
SourceFolder: '$(Pipeline.Workspace)/drop_asia'
115+
Contents: '$(Build.BuildId).zip'
116+
117+
- task: Bash@3
118+
inputs:
119+
targetType: 'inline'
120+
script: |
121+
cd /home/azureuser/azagent/_work/1/japp
122+
pm2 restart index
123+
sudo systemctl restart nginx
124+
125+
routeTraffic:
126+
steps:
127+
- script: echo routing traffic
128+
postRouteTraffic:
129+
steps:
130+
- script: echo health check post-route traffic
131+
on:
132+
failure:
133+
steps:
134+
- script: echo Restore from backup! This is on failure
135+
success:
136+
steps:
137+
- script: echo Notify! This is on success

0 commit comments

Comments
 (0)