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