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